5

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?

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

for what does the ^ stand for? one further back?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.