取消合并 git 分支,保留合并后的提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9072792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unmerge a git branch, keeping post-merge commits
提问by whatf
Say there are two branches master
and branchA
.
假设有两个分支master
和branchA
。
I work on master
, a friend on branchA
.
Once things are finalized, we merge branchA
with master
.
我工作master
,朋友上branchA
。一旦事情完成,我们将branchA
与master
.
After several commits on the merged master
, the client wants the
work done on branchA
removed, but NOT the commits done after the merge.
在对合并进行多次提交后master
,客户希望branchA
删除完成的工作,但不希望合并后完成的提交。
How can we do it?
我们怎么做?
回答by Justin ??????
Read through Pro Git - Undoing Merges.
Basically, you git revert
the merge commit:
基本上,你git revert
合并提交:
git revert -m 1 hash_of_merge_commit
You may end up with some conflicts that you'll have to manually unmerge, just like when merging normally.
您最终可能会遇到一些必须手动取消合并的冲突,就像正常合并时一样。
Additional links:
附加链接: