Search code examples
gitrm

How to undo git rm . -r --cached command without losing any uncommitted changes?


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?


Solution

  • 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.