I deleted some files from git and now want them back. I am trying to use git checkout
to restore the files.
I looked back through my history, and identified the commit where the files were deleted. When I run git checkout <sha of deleting commit> path/to/my/file
, I get
error: pathspec 'path/to/my/file' did not match any file(s) known to git.
What am I doing wrong?
Doh. The commit that deleted those files would necessarily not have them anymore. Thus, I need to go one commit further back. Running:
git checkout <sha of deleting commit>^ path/to/my/file
works perfectly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With