Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore files removed by Git checkout

Tags:

git

I have accidentally forgot to "git add ." a bunch of files that I have created before creating a new branch using "git checkout -b name" and all my un-staged files have been replaced by the files from the head.

Is there any way of retrieving these files? They are not in stash nor they have been commited. Also I am not using an IDE which keeps a history of files.

I have read about "git fsck --lost-found", but before I try that, is there any other way I can revert the un-staged files back onto the filesystem?

like image 647
Daniel Z. Avatar asked Aug 21 '12 17:08

Daniel Z.


1 Answers

Unfortunately there is no way (not that I have found). Once I did something like that, but I was using Aptana Studio and could recover all the files.

Anyway, a good practice is to maintain your commits small. When you do that you'll never loose more than 30 minutes even with accidents like that.

like image 68
hsgubert Avatar answered Sep 26 '22 06:09

hsgubert