从提交恢复特定文件
我正在使用 Git 和 GitGUI。
我提交了几个文件(并且此后再次提交),现在我看到测试不起作用。我检查了一些提交并找到了罪魁祸首。我现在想将对特定文件所做的更改恢复到某个提交。我怎样才能做到这一点?
首选解决方案还将在树中保留最新的提交(这样我这次可以很好地重新实现它们)。
I'm using Git with GitGUI.
I did a commit to several files (and have since committed again) and now I see a test is not working. I checked out some commits and found the culprit. I now want to restore the changes made to a specific file, back to a certain commit. How can I do that?
A preferred solution will also keep the latest commits in the tree (so I can re-implement them well this time).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将修订版本和文件名传递给
git checkout
进行检查出该文件的特定版本:现在您的工作副本将具有来自提交
abc123
的filename
版本,您可以提交该版本以恢复到该版本那个文件。You can pass a revision and filename to
git checkout
to check out a particular version of that file:Now your working copy will have the version of
filename
from commitabc123
, and you can commit that in order to restore back to that version of that file.