0

I have forked a git repo and then later deleted a file in the fork and committed changes to the fork. Is there a way to just get this one file back from the original repo? Is this possible without having to revert my delete commit in the fork?

4

1 Answer 1

4

Certainly, you can get the file back even from your repo. Remember, your clone contains a copy of the entire history, meaning every commit — and every commit contains all your files at the time of the commit, and no commit is ever lost. You just need to know the SHA of the last commit before the commit that deleted it. Then git checkout <SHA-of-commit> -- <path-of-file>.

Not the answer you're looking for? Browse other questions tagged or ask your own question.