How do I undelete a file after git rm and pushing to github?

Alex Chao picture Alex Chao · Oct 7, 2013 · Viewed 16.2k times · Source

I recently cloned a repository on my local machine and then did a git remove on one of the files and pushed those changes back to the github repository. My question is how do I restore that file back on the original github repository?

Answer

acj picture acj · Oct 7, 2013

If you can find a previous commit abcd that has the deleted file, then you can use

git checkout abcd file-to-restore

to restore it. You'll need to commit the file again.