-1

I would like to restore a file that I deleted within a commit. I tried

git checkout path/to/deleted/file

but got

error: pathspec 'path/to/deleted/file' did not match any file(s) known to git.

How can I restore a file deleted by my latest commit?

amphibient
  • 29,770
  • 54
  • 146
  • 240

1 Answers1

1

Also specify the last commit where the file was still present.

git checkout <commit> path/to/deleted/file
SzG
  • 12,333
  • 4
  • 28
  • 41