简体   繁体   English

如何通过ID恢复为先前的提交

[英]How to revert to previous commit by ID

I have a commit id of "a9a6de2" within my list of commits that's a few versions old. 我的提交列表中的提交ID为“ a9a6de2”,该列表的版本较旧。

What's the git command to revert to that commit? 恢复到该提交的git命令是什么?

to create a new branch that matches that SHA 创建一个与该SHA匹配的新分支

git checkout -b YOUR_BRANCH a9a6de2

To make the currently checked out branch match that sha --Not working directory safe --Do not to to push this to a remote server 为了使当前已签出的分支与该sha相匹配-不工作目录安全-请勿将其推送到远程服务器

git reset --hard a9a6de2

Note that git revert does a subtractive patch of the SHA specified (and only the SHA specified), which doesn't sound at all like what you want. 请注意, git revert对指定的SHA(仅指定的SHA)执行减法补丁,听起来根本不像您想要的那样。 I understand this is a common source of confusion for Subversion users because 'revert' behaves differently in Subversion. 我知道这是Subversion用户的常见困惑来源,因为“还原”在Subversion中的行为有所不同。

Sounds like you want to revert that commit 听起来您想还原该提交

$ git revert a9a6de2 should do it $ git revert a9a6de2应该这样做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM