简体   繁体   English

从主分支中删除单个合并分支

[英]Remove a single merged branch from master branch

In my master branch, there're following local branches that have been merged, but I would like to remove the local_branch3 from master: 在我的主分支中,有以下已合并的本地分支,但我想从master中删除local_branch3

local_branch1
local_branch2
local_branch3
local_branch4

after removing the local_branch3 from master, I would like it to remain a local branch (only deleted from master). 从master中删除local_branch3之后,我希望它保留为本地分支(仅从master中删除)。

I've check Steve Harman's blog on this similar issue, but that seems also deleting the local branch for ever. 我在这个类似的问题上检查了Steve Harman的博客 ,但这似乎也永远删除了本地分支。

Edit: to clarify what I meant, as I posted in one of the below comments: 编辑:澄清我的意思,正如我在以下评论中发表的那样:

I would like the master branch to undo the changes resulting from local_branch3 merging, while leaving local_branch3 untouched. 我希望master分支撤消local_branch3合并产生的更改,同时保持local_branch3不变。

The reason being that I would like to keep the master branch deliverable while I tweak on local_branch3 . 原因是我想在local_branch3调整时保持master分支的可交付local_branch3

Maybe you mean reverting local_branch3 from master? 也许你的意思是从master恢复local_branch3?

If so, first check SHA1 value of the commit which merges local_branch3. 如果是这样,首先检查合并local_branch3的提交的SHA1值。 And

git checkout master
git revert -m 1 <<SHA1 value>>

Then no local_branch3 codes in master branch. 然后在master分支中没有local_branch3代码。 And locah_branch3 will remain. 并且locah_branch3将保留。

If I'm reading the question right, shirakia's answer (revert the merge commit's changes) is the right one, it works as advertised and OP should use it. 如果我正在阅读正确的问题,那么shirakia的答案(恢复合并提交的更改)是正确的,它的工作方式与广告一样,OP应该使用它。

But it's worth pointing out what happens if further work on local3 makes the whole of it valid, and you naturally want to reapply the original work along with those later corrections. 但值得指出的是,如果对local3的进一步工作使整个有效,并且您自然希望重新应用原始工作以及后来的更正,会发生什么。

The local3 commits as of that merge are now part of the merge commit's history. 从该合并开始的local3提交现在是合并提交历史的一部分。 Because the base content for any further merges from local3 is at the new merge base, all of that history is effectively marked as (really, it has been) already correctly applied: any later merge sees only changes made since then. 因为来自local3的任何进一步合并的基本内容位于新的合并基础上,所有该历史记录都被有效地标记为(实际上,它已经)已经正确应用:任何后来的合并只会看到自那时以来所做的更改。 The revert didn't undo that part (in fact, that was the whole point of the revert, to not remove that commit). 恢复并未撤消该部分(事实上,这是恢复的全部内容,不删除该提交)。

Here's a well-known discussion of how to reapply the changes if further development on local3 makes the whole thing mergeable again (you revert the revert, you put the changes back yourself) . 这里有一个众所周知的讨论如何重新应用这些更改,如果local3上的进一步开发使整个事情再次合并(你还原恢复,你自己把更改)

Another perhaps simpler way of putting it is, the right way to undo any commit you don't want to remove from your history is to revert it. 另一个可能更简单的方法是,撤消任何你不想从历史记录中删除的提交的正确方法是还原它。 That includes any later decision to undo the reversion. 这包括任何后来撤销回归的决定。

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

相关问题 功能分支合并推送后,从主分支中删除功能分支的提交消息 - Remove commit messages of feature branch from master branch after feature branch is merged and pushed git:从master分支中删除单个提交 - git: remove single commit from the master branch 如何在github上删除以前与master合并的分支 - How to remove previously merged branch with master on github 我在git的错误分支上创建了一个分支,并将旧分支合并到master中,如何从另一个分支中删除提交? - I created a branch off of the wrong branch in git and already merged the old branch into master, how do I remove the commits from the other branch? 如果一个分支从未合并到 master 中,删除该分支是否也会从 repo 中删除它的提交? - if a branch is never merged into master, will deleting that branch also remove its commits from the repo? 从主分支恢复合并的更改 - Revert merged changes from master branch 从主分支恢复合并的拉取请求 - Revert a merged pull request from master branch 如何还原master的合并分支? - How to revert back the merged branch from master? 从另一个分支重新设置基础,然后在合并另一个分支后合并到master - Rebase from another branch and then merge into master after merged the other branch 从master分支中删除所有内容 - Remove everything from the master branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM