复杂的git rebase机动 [英] Complex git rebase maneuver
问题描述
看看 git-rebase
手册页,我没有看到任何看起来像我想要的图表(除了一些似乎与我想要的相反),并玩弄 - 到
没有得到我想要的。
让我看看是否可以绘制类似于 git-rebase
手册页中的图酒吧的左边是正确的Markdown格式):
| o-o-o-o-branch2
| /
| -ooA-master-o-branch1-oo-my_WIP_branch
branch1
在这里实际上可能并不重要,但我仍然将它包括在内。我想要做的就是得到这个(省略通常伴随着
git-rebase
手册页图的'
):
| o-o-o-branch2-o-branch1-o-o-my_WIP_branch
| /
| -ooA-master
基本上,我想把 my_WIP_branch
工作在分支2
上,而不必处理标记为 A
。有没有办法做到这一点,而不是手动樱桃采摘 branch2
的每个提交(或者至少有可能是一个简单的方法来做到这一点?)?顺便说一句,会有合并冲突,所以理想情况下它应该是一个git命令或一组git命令来优雅地处理它们(例如, git rebase
优雅地处理它们, code> git am 和 git apply
不)
奇怪...因为这应该是 rebase --onto
。
您有:
oooo< - branch2
/
oooA< - master
\
-oo < - branch1
\
-oo < - my_WIP_branch
您要:
-oo < - my_WIP_branch
/
-oo < - branch1
/
oooo< - branch2
/
oooA& lt; - master
应该是:
$ git rebase --onto branch2 master my_WIP_branch
它会重播任何不在master上的提交,但是从你可以访问到的位置my_WIP_branch(意味着来自branch2的提交不符合条件)。
请参阅我的其他SO合并冲突说明的答案, href =http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#resolving-a-merge =nofollow noreferrer>解决合并冲突部分 Git手册。 (您可以接受与 版本的所有合并,例如)
Looking at the git-rebase
man page, I didn't see any diagrams that looked like what I want (except some seem to do the reverse of what I want), and playing around with --onto
didn't get me what I wanted either.
Let me see if I can draw a diagram like the ones from the git-rebase
man page (the vertical bars to the left are to make Markdown format it correctly):
| o-o-o-o-branch2
| /
| -o-o-A-master-o-branch1-o-o-my_WIP_branch
branch1
is probably not actually important here, but I included it anyway. What I want to do is get this (omitting the '
s that that usually accompany the git-rebase
man page diagrams):
| o-o-o-o-branch2-o-branch1-o-o-my_WIP_branch
| /
|-o-o-A-master
Basically, I want to put my my_WIP_branch
work over the branch2
work without having to deal with merge conflicts involved in the group of commits labeled A
. Is there any way to do this other than manually cherry-picking each commit over branch2
(or at least is there maybe an easy way to do that?)? By the way, there will be merge conflicts, so ideally it should be a git command or group of git commands that handle those gracefully (e.g., git rebase
handles them gracefully, git am
and git apply
do not).
Strange... because this should be a classic case of rebase --onto
.
You have:
o-o-o-o <--branch2
/
o-o-o-A <--master
\
-o-o <--branch1
\
-o-o <--my_WIP_branch
You want:
-o-o <--my_WIP_branch
/
-o-o <--branch1
/
o-o-o-o <--branch2
/
o-o-o-A <--master
That should be:
$ git rebase --onto branch2 master my_WIP_branch
it will replay any commit not on master, but from where you can reach my_WIP_branch (meaning the commits from branch2 are not eligible).
See my other SO answer for merge conflict instructions, and the "resolving merge conflicts" section of the Git manual. (you can accept all merges with your version, for instance)
这篇关于复杂的git rebase机动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!