Is it possible to recover deleted files that were added but not committed to Git?

I am new to git and I just made a silly mistake that I deleted some important files with the "rm *" command. However, I used "git add" to add these files, but not to commit. delete has not been added yet. So, is there a way to recover these deleted files.

Any suggestions or answers would be appreciated. Thank you

+5
source share
2 answers

Since the files are already in your staging area (index), just pass them in with git commitno arguments. This will capture the contents of the index regardless of the current state of the working tree.

git reset --hard ( , ) git checkout FILE1 FILE2..., .

+7

git fsck --lost-found, , . "blob" , , . , .


4815162342, , , , git checkout , , .

, - git fsck --lost-found, user4815162342 .

+6

All Articles