如果我有以下内容:
A---B---C-----D-- branch dev
\--C'-E-/ branch test
我做得不好:C 和 C' 几乎是相同的提交,如果我可以让分支 test 从 C 而不是 B 开始会更有意义。
我该怎么做?我猜是 rebase,但我不确定如何使用它,thx
编辑:不清楚 我想要什么:
A---B---C-----D-- branch dev
\-E-/ branch test
或
A--B--D--E--D 如果不可能的话
最佳答案
您可以在临时分支(由 C
制作)之上对其进行 rebase
参见 git rebase
和 Rebasing , 加上 git branch
.
git branch tmp C
git checkout test
# rebase the current branch (test) on top of tmp
git rebase tmp
git branch -d tmp
那应该给你:
A---B---C-----D-- branch dev
\--C''-E'-/ branch test
我离开了 C'(此处为 C''),因为 C' 与 C 不完全相同。
但是作为ams评论,如果你需要 C' 走了,你会
git rebase -i tmp
这将使您获得一个交互式 rebase,允许完全删除 C'
,仅在 之上重播
.E
C
关于git 更改分支的起源(rebase),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10976938/