Reputation: 139
I've accidentally executed a git rm . -r --cached
command which makes all files have deleted status. I have some uncommitted changes which I do not want to lose. How can I undo the effects of git rm . -r --cached
command and return to the previous state without losing any uncommitted changes?
Upvotes: 2
Views: 2962
Reputation: 1772
Just add them again with: git add .
The command you ran doesn't remove the files from the disk, just from the index. So, add them back.
Upvotes: 3
Reputation: 40070
Since you used the --cached
option, only your index has been modified. Your working directory has been left as is. You can simply git add
files marked as deleted.
Upvotes: 7