简体   繁体   English

从已推送的合并分支恢复特定提交

[英]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.

相关问题 如何重做已经合并到另一个分支中的提交 - How to rework a commit that has already been merged in an another branch 如果您已经将文件推送到远程分支,合并到开发分支并且它不是最新提交,如何从 git 中完全删除文件 - How to completely remove a file from git if you already pushed it to the remote branch, merged to the develop branch and it is not the latest commit git:如果已将分支推送到日志中并且不存在,如何还原将一个分支移动到另一分支的操作 - git: how to revert the operation of moving one branch to another if it has been already pushed and it does not exist in the log Git:如何删除已经提交,推送并合并到master的分支? - Git: How do I remove a branch that has already been committed, pushed, and merged into master? 如何恢复已经推送到远程分支的合并提交? - How to revert a merge commit that's already pushed to remote branch? 重新设置已经合并的分支 - Rebase a branch that has already been merged 将推送的分支恢复为具体提交 - Revert pushed branch to a concrete commit 当合并分支已合并并已恢复时,如何强制进行合并提交? - How do I force a merge commit when the branch being merge has been merged and reverted already? Git - 如何恢复已推送到远程分支(不是原点)的变基 - Git - How to revert a rebase that has been pushed to the remote branch (not origin) Git-将大型提交历史记录从“推送的头”还原到错误的分支 - Git - Revert Large commit history from Pushed Head to wrong branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM