压缩原始分支中的提交后如何重新设置基础? [英] How to rebase after squashing commits in the original branch?
本文介绍了压缩原始分支中的提交后如何重新设置基础?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有
A--B--C master
\
D branch0
然后将B
和C
压入B'
.
如何重新设置branch0
使其看起来像这样:
Then I squash B
and C
into B'
.
How do I rebase branch0
such that it looks like this:
A--B' master
\
D branch0
推荐答案
使用--onto
参数对git rebase进行设置,这将更改git重放的基线.
Use the --onto
argument to git rebase, which changes the baseline that git replays work on.
git checkout branch0
在此状态下,您仍应在git历史记录中看到 C .
At this state you should still see C in your git history.
git rebase --onto B' C
这表示:从提交 C (在您的情况下为 D )中获取我当前分支中的所有提交,然后在顶部播放> B'
This translates to: Take all commits in my current branch since commit C (In your case that's just D) and play back on top of B'
您还可以使用可选的<branch>
参数同时进行结帐和重新设置基数:
You can also use the optional <branch>
argument to do both the checkout and rebase at once:
git rebase --onto B' C branch0
这篇关于压缩原始分支中的提交后如何重新设置基础?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文