git 如何恢复已删除的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1843577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to restore deleted file
提问by Steve Emmerson
Possible Duplicate:
Restore a deleted file in a Git repo
可能的重复:
在 Git 存储库中恢复已删除的文件
How do I restore a file I accidentally removed from my git
repository? I know this is a trivial question, but I haven't found the answer in the documentation.
如何恢复不小心从git
存储库中删除的文件?我知道这是一个微不足道的问题,但我还没有在文档中找到答案。
回答by wulfovitch
git checkout <commit> <path>
git checkout <commit> <path>
Commits may be specified directly by SHA1, or via a branch or tag. Make sure that the represents the state of the repository when the deleted file was still present. If the commit argument is omitted, the currently checked out commit (HEAD) will be used.
提交可以由 SHA1 直接指定,也可以通过分支或标签指定。确保 代表被删除的文件仍然存在时存储库的状态。如果省略 commit 参数,则将使用当前检出的提交 (HEAD)。