在master上提交后git更新分支 [英] git update branch after commit on master
问题描述
我有以下回购结构:
MA --- o --- o --- o --- T1-
|
B1 \ --- o--
|
B2 \ --- o --- o
其中 MA
是 master
, B1
和 B2
是分支, o
是提交, -
是开发,是某个时间点
现在你看到,在我对 MA
进行了第一次提交之后,我创建了一个新分支 B1
。然后在 B1
上工作,然后创建 B2
并开始处理它。
现在我的问题是,在创建分支之后,我对 这里有两个问题: 当然:rebase 现在一个 这将给出: I have the following repo structure: where Now you see that after I did the first commit on My problem is now that I did two more commits on So couple of questions here:
Sure: rebase At this staged, Now a That will give:
这篇关于在master上提交后git更新分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! MA
做了两次更多的提交。但我希望整个分支发生在 T1
- 这样我的 B1
所有3个主提交都作为基础。
B1
?
如果我管理 repoint
B1
?我想保留 B2
以 B1
为基础提交的事实
B1
,然后 B2
。
您只需在做之前标记旧的B1状态:
git checkout B1
git branch oldB1
git rebase MA
B2
不变:
MA --- o-- -o --- o --- T1 --- o B1
|
oldB1 \ --- o
|
B2 \ --- o --- o
rebase --onto
将移动 B2
提交( oldB1
头部之一 - 排除 - 高达 B2
HEAD - 包括 - )。
git checkout B2
git rebase --onto B1 oldB1 B2
git branch -d oldB1
MA --- o --- o --- o --- T1 --- o B1
|
B2 \ --- o --- o
MA ---o---o---o---T1-
|
B1 \---o--
|
B2 \---o---o
MA
is master
, B1
and B2
are branches, o
is commit, -
is development and T1
is some time pointMA
, I created a new branch B1
. Then worked on B1
, then created B2
and worked on it as well.MA
after I have created the branches. But I want that the whole branching happens at time T1
- so that my B1
have all 3 master commits as basis.
B1
?B2
if I manage to repoint B1
? I want to preserve the fact that B2
has the commit on B1
as basisB1
, then B2
.
You only needs to mark the old B1 state before doing it:git checkout B1
git branch oldB1
git rebase MA
B2
is unchanged:MA ---o---o---o---T1---o B1
|
oldB1 \---o
|
B2 \---o---o
rebase --onto
will move B2
commits (the one between the oldB1
HEAD -- excluded -- up to B2
HEAD -- included --).git checkout B2
git rebase --onto B1 oldB1 B2
git branch -d oldB1
MA ---o---o---o---T1---o B1
|
B2 \---o---o