使用场景
某个文件曾在Gi仓库里的,某次提交commit时删除了该文件,后来想要恢复,怎么办呢?
步骤
-
首先需要找到在哪个commit里该文件被删除:
git rev-list -n 1 HEAD -- <file_path>
-
接着通过该commit id,恢复该文件
git checkout <deleting_commit>^ -- <file_path>
参考Stackoverflow的帖子
https://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repository
网友评论