[英]What happens to the child branch when I have squashed the commits from parent branch and merged it into master?
My branching looks like this我的分支看起来像这样
M1 --- M2 --- M3 --- ............. --- M50 --- M51
\
\
P1 --- P2 --- P3 --- P4
\
\
C1 --- C2 --- C3
Here M is master commits P is parent branch commits C is child branch commits这里 M 是主提交 P 是父分支提交 C 是子分支提交
I was developing a feature(F1) and created a branch(Parent) and had commits until P3.我正在开发一个功能(F1)并创建了一个分支(父)并提交到 P3。 At this point I started working on new feature(F2), but since I needed P3 commit changes to work on new feature I created a branch(child) at P3.
在这一点上,我开始研究新功能(F2),但由于我需要 P3 提交更改才能处理新功能,因此我在 P3 处创建了一个分支(子)。 I got one review comment for feature F1 and had committed P4 in parent branch.
我收到了一条关于功能 F1 的评论评论,并在父分支中提交了 P4。
There was no conflict so I rebased the child branch to get something like this.没有冲突,所以我重新设置了子分支以获得这样的东西。
M1 --- M2 --- M3 --- ............. --- M50 --- M51
\
\
P1 --- P2 --- P3 --- P4
\
\
C1 --- C2 --- C3
Now my parent branch commits are squashed and merged with master at M52.现在我的父分支提交被压缩并在 M52 与 master 合并。 Here I am confused on what happens with my child branch.
在这里,我对我的子分支会发生什么感到困惑。 I guess it is like this.
我想是这样的。
M1 --- M2 --- M3 --- ............. --- M50 --- M51 -- M52(contains squashed commits of P1-P4)
\
\
C1 --- C2 --- C3
If my guess is correct then what should be the right command to achieve something like this?如果我的猜测是正确的,那么实现这样的事情的正确命令应该是什么? Please let me know and next step if my guess is wrong too.
如果我的猜测也是错误的,请让我知道和下一步。
M1 --- M2 --- M3 --- ............. --- M50 --- M51 -- M52
\
\
C1 --- C2 --- C3
I believe it is again a rebase with onto, but I am not sure what it should be exactly?我相信它又是一个 on 的变基,但我不确定它到底应该是什么? Plenty of teams work and merge their branches on master, so I don't want to take risk with wrong commands myself.
许多团队在 master 上工作并合并他们的分支,所以我不想自己冒险使用错误的命令。
Thanks in advance.提前致谢。
After the "squash & merge" of your parent branch, your history will look like this :在您的父分支的“挤压和合并”之后,您的历史将如下所示:
M1 --- M2 --- M3 --- ............. --- M50 --- M51 --- M52
\
\
P1 --- P2 --- P3 --- P4 # <- the 'Pxx' commits still exist
\
\
C1 --- C2 --- C3
The rebase command you are looking for is :您正在寻找的变基命令是:
git rebase --onto M52 P4 child
After that, you will have to force push your child
branch to update it on the remote repo :之后,您将不得不强制推送您的
child
分支以在远程仓库上更新它:
git push --force-with-lease origin child
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.