I had a bunch of changes added to the staging index by git add *
, but not yet commited, I wanted to remove them, undo the add, so I did git rm -rf .
to my surprise it removed them from my hard drive, I want a way to get them back; however, I have made huge changes and I would like to get those changes back.
TLDR: I deleted my whole project by git rm -rf .
, I need some way to reset the deletion, so that I keep my uncommited changes and get my files back. please I am too scared that I might lose my whole project.
ANSWER: My repository is basically a website with a lot of content, Based on the answers below, I made 2 copies of my repository, let's call them copy A and copy B, for A I did git reset --hard
to go back to the latest commit, I got my files back, but lost the changes I made to them. so for copy B I did git fsck --lost-found
and went into the .git/lost-found/other/ directory which contained multiple hash-named versions of my files, I kept opening each of them, they were more than 60 files btw, each file I recognize I rename it to it's actual name and then place it instead of the older versions inside of copy A, at the end I deleted my original repo and I am using copy A now as my website. it is as thought nothing have happened now. One Little Stupid Mistake => 5 Hours of Pain. Don't repeat what I did, never ever.
right now git status
shows all my files as "deleted: " and its in green.