GIT-在GIT repo中还原已删除的文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GIT-在GIT repo中还原已删除的文件相关的知识,希望对你有一定的参考价值。
Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I find I need to restore that file.
/* Find the last commit that affected the given path. As the file isn't in the HEAD commit, this commit must have deleted it.*/ git rev-list -n 1 HEAD -- <file_path> // Then checkout the version at the commit before git checkout <deleting_commit>^ -- <file_path> ############################################################################################## // Or in one command, if $file is the file in question. git checkout $(git rev-list -n 1 HEAD -- <file_path>)^ -- <file_path>
以上是关于GIT-在GIT repo中还原已删除的文件的主要内容,如果未能解决你的问题,请参考以下文章