I committed a file to my local git and then pushed it to github.
I performed the following commands to remove that file and then pushed it to github:
git rm file.txt git commit -m remove file.txt git push -u github master
I then realized that I want the file back. I tried the instructions outlined here: https://www.quora.com/How-can-I-recover-a-file-I-deleted-in-my-local-repo-from-the-remote-repo-in-Git
I ran the following command:
git rev-list -n 1 HEAD -- file.txt
which gave me a hash for the version which had my file: HASH. Which I then used in the following command:
git checkout HASH^ file.txt
Which then gave me the following error:
error: pathspec 'file.txt' did not match any file(s) known to git
Luckily, I was able to go to github and recover all of my files from there, but I still don't known how to do it locally, or even if it's possible.