git Git将一个分支合并到另一个分支是一种双向合并吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15258375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:40:38  来源:igfitidea点击:

Git merging one branch into another is a two way merge?

gitmergegit-mergemeld

提问by EMiller

My git repo looks like this:

我的 git repo 看起来像这样:

         _ branch_a
        /
master /
        \_ branch_b

Now I want to merge branch_b into branch_a, noteither branch into master.

现在我想将 branch_b 合并到 branch_a,不是分支到 master。

So, I did

所以我做了

git checkout branch_a
git merge branch_b

And git went and found a couple of conflicts.

git 去发现了一些冲突。

When I do git mergetoolusing meldwhat I get on the console is

当我git mergetool使用meld我在控制台上得到的东西时

 {local}: modified file
 {remote}: modified file

and a window showing only LOCAL and REMOTE.

以及一个仅显示 LOCAL 和 REMOTE 的窗口。

What I want to know is:

我想知道的是:

  1. Why isn't the shared base of what was in master shown?

  2. Between LOCAL and REMOTE, which one am I supposed to edit?

  1. 为什么没有显示 master 中的共享基础?

  2. 在 LOCAL 和 REMOTE 之间,我应该编辑哪一个?

回答by iberbeu

If you merge a branch A into a branch B the conflicts that you get come from the difference between both branches and not from the difference with master. executing git diffin A or B will give you however the diff with mastere since it is the ancestor

如果您将分支 A 合并到分支 B,则您得到的冲突来自两个分支之间的差异,而不是来自与 master 的差异。git diff在 A 或 B 中执行会给你但是与 mastere 的差异,因为它是祖先

Normally the localbranch should be the one you are merging intoand the remotethe one you want to merge. Anyway in your computer you will only have one copy of the file so just modify it

通常情况下,当地的分支应该是你是一个融入远程想要一个合并。无论如何,在您的计算机中,您将只有一份文件副本,因此只需对其进行修改即可