简体   繁体   English

git:合并后更新2分支

[英]git: update the 2 branch after a merge

This is a newbie question. 这是一个新手问题。 I have 2 branches, branch_A and branch_B . 我有2个分支, branch_Abranch_B I am in branch A and do a merge with this command: 我在分支A中,并使用以下命令进行合并:

git checkout branch_A
git merge --commit -m "my commit" branch_B

If there is no conflict, it automatically does the merge and updates the branch_A to new commit. 如果没有冲突,它将自动进行合并,并将branch_A更新为新提交。 But branch_B is still in same place. 但是branch_B仍然在同一位置。

How can I update the branch_B to point in same place than branch_A? 如何更新branch_B使其指向与branch_A相同的位置?

This is a bit unusual, since most of the time you don't need a branch you've merged. 这有点不寻常,因为在大多数情况下,您不需要合并的分支。 So ask yourself if it is really what you want. 因此,问问自己,这是否真的是您想要的。

If it is, the simplest solution is to merge branch_B with branch_A . 如果是这样,最简单的解决方案是将branch_Bbranch_A合并。 It won't create a merge commit, because it can be fast-forwarded, but it will point to the same place as branch_A . 它不会创建合并提交,因为它可以快速转发,但是它将指向与branch_A相同的位置。 Commands are: 命令是:

git checkout branch_B
git merge branch_A

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM