[英]Revert a specific commit from a merged branch that has already been pushed
I was just reading the post below and I had a question I was hoping someone would know the answer to. 我刚刚阅读下面的帖子,我有一个问题,我希望有人知道答案。
How to revert a merge commit that's already pushed to remote branch? 如何还原已经推送到远程分支的合并提交?
So I know that I can completely revert a merge commit from my master by specifying its parent branch in the git revert -m command. 所以我知道我可以通过在git revert -m命令中指定其父分支来完全恢复主服务器的合并提交。 My question is can I revert a single commit from that merged branch rather than the entire branch.
我的问题是我可以从合并的分支而不是整个分支恢复单个提交。
For example I branch from master to feature_1 branch. 例如,我从master分支到feature_1分支。 I make 14 commits on the feature_1 branch and merge back to my master, which I then push.
我在feature_1分支上做了14次提交并合并回我的主人,然后我推送。
How would I go about removing commit 7 of the merged branch from the master while leaving the other 13 in the master. 如何从主服务器中删除合并分支的提交7,同时将其他13分支保留在主服务器中。 Hopefully its possible and thanks in advance for any replies or comments.
希望它可能并提前感谢任何回复或评论。
Step 1: Identify the <sha1>
of the commit you'd like to revert. 第1步:确定您要还原的提交的
<sha1>
。
Step 2: Do this on the master branch: 第2步:在主分支上执行此操作:
$ git revert <sha1>
That will create a new commit that revert the commit identified by <sha1>
. 这将创建一个新的提交,以恢复由
<sha1>
标识的提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.