Nothing has been lost!
The Git reflog records all commits made on local branches ("references" or "refs" for short) and also for all commits that HEAD
pointed to.
Run git reflog
and you should see all commits made during your aborted rebase process. The reflog should contain an entry "rebase (abort): returning to ...".
Use git log
or gitk
to inspect this commit (or any other commit of the reflog) and then git branch hash-of-that-commit
to create a new branch pointing to that commit. You can then switch to that branch to extract the files.
As to why the files were removed when aborting the rebase: Git only leaves untracked files alone during its operations. Once you tracked these files (intentionally or not), they became managed by Git. Switching branches or checking out different commits will remove (tracked) files from your working tree which are part of the "previous" commit but not part of the to-be-checked-out commit.
The good thing is that Git doesn't easily lose data that has been committed once.
If files never were committed, but the content of the file was staged (with git add
), then it is still possible to recover the content, but it is a bit more work. Run git fsck
to find any dangling blobs and then use git cat-file -p
or git show
with the object id of the respective blob. Once you have found the correct blob(s), redirect the output of cat-file
/show
to a file with the desired name. Repeat for all your files.