简体   繁体   English

当我压缩来自父分支的提交并将其合并到主分支时,子分支会发生什么?

[英]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.

相关问题 合并到 master 时,第一个分支被压扁后合并分支的一个分支 - Merging a branch of a branch after first branch is squashed when merged to master SQUASHED时检查Git分支是否已合并为主分支? - Checking if a Git branch has been merged into master when SQUASHED? PR 用于从被压扁和合并的前一个分支创建的分支显示前一个分支的提交 - PR for branch made from previous branch that was squashed and merged shows previous branch's commits GIT:如果我将所有提交压缩到一个分支上然后合并到master上,那么与master进行的先前合并会发生什么? - GIT: What happens to previous merges from master if I squash all commits on a branch and then merge it onto master? 分支机构的家长被压榨怎么办? - What to do when parent of branch was squashed? 如果将父分支合并到主分支,子分支会发生什么? - What Happens To Child Branches If You Merge The Parent Branch Into Master? 如果我在git中删除父分支,子分支会发生什么 - What happens in the child branch if I delete a parent branch in git 我在git的错误分支上创建了一个分支,并将旧分支合并到master中,如何从另一个分支中删除提交? - I created a branch off of the wrong branch in git and already merged the old branch into master, how do I remove the commits from the other branch? 当我在master分支上时从另一个分支拉出时会发生什么 - What happens when I pull from a different branch while I am on the master branch 分支分支合并后会发生什么 - What happens when branched branch gets merged
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM