Reputation: 177
I cannot remember exactly what I did, but I think it was running git rm -r --cached *
. I wanted to remove all files from staging. To my surprise, the repo's .gitignore
file was removed... although I am sure it will not surprise many of you.
How can I get that specific file back from a previous commit?
Upvotes: 1
Views: 56
Reputation: 692
You can use git checkout to get a specific file by providing a commit number and the file name.
git checkout [commit-ref] -- [filename]
Upvotes: 3
Reputation: 30307
git checkout HEAD -- .gitignore
will put it back on the working tree.
Upvotes: 1