-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
  • 27,548
  • 48
  • 136
  • 231

1 Answers1

1

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

git checkout <commit> path/to/deleted/file
SzG
  • 11,777
  • 4
  • 25
  • 38