git checkout 从先前的分支恢复文件:pathspec 与 git 已知的任何文件都不匹配

sto*_*tic 5 git

我从 git 中删除了一些文件,现在想要它们回来。我正在尝试使用git checkout来恢复文件。

我回顾了我的历史,并确定了文件被删除的提交。当我跑步时git checkout <sha of deleting commit> path/to/my/file,我得到

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

我究竟做错了什么?

sto*_*tic 7

多。删除这些文件的提交必然不再拥有它们。因此,我需要进一步提交一次。跑步:

git checkout <sha of deleting commit>^ path/to/my/file

完美运行