Git: Undo git rm on one file

Pretend we just did a “git rm” but realized that we wish to keep one file we just removed.

git checkout HEAD path/to/file

This will simply checkout the file from the HEAD revision.

Another alternative is to use git reset if it is more files and no other changes are uncommitted (or stage before doing the reset)

3 thoughts on “Git: Undo git rm on one file

Comments are closed.