Wednesday, August 4, 2010

Git back here

If you used the git rm command, ignored the warning, you will notice that the file doesn't get removed from your repository, it gets removed from your file system.  There is no trash bin with git either.  You might be in luck if you did a git add first, then issued the git rm command.  Your file will have been hashed and added to the git staging area.  You can retrieve that file by issuing the following command:

git fsck --lost-found

This will pull all the files out of the staging area and drop them in the folder .git/lost-found/other.  One catch though.  The file isn't named as you would think, or hope.  The file is named with its hash value.  This is ok, you haven't lost the contents of the file, just the file name.  If you poke around in the files a bit, you'll find what you are looking for.  Its not perfect, but the content is there.  And yes, I did do this.

No comments: