git取消合并分支 [英] git unmerge a branch
问题描述
我正在使用Mac的sourceTree作为我的GUI,因此我会很感谢使用它的说明,但是显然我想学习bash命令作为我的第一语言.
I am using sourceTree for Mac as my GUI so I would appreciate instructions on using it but obviously I would like to learn the bash commands as my first language.
我们有一个称为develop
的远程仓库,实践是,在开发功能时,您从develop
为该功能创建分支,例如feature1
,将其下拉,然后提交您创建的分支上的拉取请求.
We have a remote repo we call develop
, and the practice is, when you develop a feature, you create a branch from develop
for that feature, for example feature1
, pull it down, and then submit a pull request on the branch you created.
我最近开发了一些我不想放入远程代码库的分析工具(无论如何).
I have recently developed some analysis tools which I don't want to get put into the remote code base (yet, anyway).
在本地,如何将analysis
分支与feature1
分支合并以进行测试,然后在完成后取消合并analysis
?
How would I, locally, merge my analysis
branch with my feature1
branch for testing, and then unmerge analysis
after I'm completed?
feature1
或analysis
,我在合并时应该检查出哪个分支?
Which branch should I have checked out at the time I do the merge, feature1
or analysis
?
注意:我想将对分支合并时所做的所有文件更改保留到feature1
中; analysis
中的文件和编辑与我的功能分支极不可能发生冲突,因此本质上我要添加一些非冲突的代码,然后将其拉出;因此我对feature1
所做的任何提交,我都不想丢失.
NOTE: I want to retain all the file changes to feature1
I did while the branches were merged; the files and edits from analysis
are extremely unlikely to conflict with my feature branch, so essentially I'm adding in some non-conflicting code, then pulling the branch out; so any commits I have done to feature1
, I don't want to lose.
推荐答案
要取消合并分支,您可以像这样简单地git revert
合并提交:
To unmerge a branch, you can simply git revert
the merge commit like so:
git checkout feature_branch
git revert -m 1 <merge_commit_sha>
就像正常合并时一样,您可能会遇到一些必须手动解除的冲突.
It is possible that you will end up with some conflicts that you'll have to manually unmerge, just like when merging normally.
这篇关于git取消合并分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!