如何将更改与develop分支合并到功能分支

时间:2014-10-09 15:33:57

标签: git svn github version-control merge

情况

  1. git branch
    • 开发
    • 特征/一个
    • 特征/ 2
  2. feature/onefeature/two相同,从develop分支出来,因此develop分支也与功能分支相同。

  3. feature/one已更新,请说已编辑foo.css

    body {
      background: #fff; /* new code */
      height: 100%;
    }
    
  4. git checkout develop && git merge feature/one

  5. feature/two也已更新,忘记在更新前从开发分支合并,添加几个文件,并且还向foo.css添加了一些css。

    body {
      height: 100%;
    }
    
    .bar {
      color: #000;
    }
    
  6. 现在,我还没有从feature/two上演任何内容,因为我知道当我上台并提交时,如果我git add --all && git commit -m "some commit message" && git merge develop,我会在foo.bar上发生冲突

  7. 问题

    这是什么情况,我试图避免文件冲突,因为它感觉不对,当我做git mergetool时,它会创建其他文件,如REMOTE,ORIG,LOCAL和I很难理解那些是什么,但我知道,我应该通过编辑<<<<<======

    之间的行来决定应该保留哪行代码

    我知道这几乎是一般情况,其中功能分支事先并不知道开发分支上有变化,因此在编辑之前它们将无法合并,或者它可能是它真正的一部分要在功能分支上执行任何操作之前先从develop分支合并的工作流程吗?

1 个答案:

答案 0 :(得分:0)

您只是发生了正常的合并冲突。尝试一些合并工具,然后配置Git使用你觉得舒服的。 REMOTE,ORIG,LOCAL是对应于&#34;他们&#34;,&#34; merge-base&#34;和&#34;你的&#34;的临时文件。版本的文件。除了最简单的合并之外,我不建议手动编辑合并冲突标记。

然后调整以下git配置设置

trustExitCode - 通常为真

keepBackup - false

keepTemporaries - false

提示 - 错误

mergetool.<tool>.trustExitCode
For a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful. If this is not set to true then the merge target file timestamp is checked and the merge assumed to have been successful if the file has been updated, otherwise the user is prompted to indicate the success of the merge.

mergetool.keepBackup
After performing a merge, the original file with conflict markers can be saved as a file with a .orig extension. If this variable is set to false then this file is not preserved. Defaults to true (i.e. keep the backup files).

mergetool.keepTemporaries
When invoking a custom merge tool, git uses a set of temporary files to pass to the tool. If the tool returns an error and this variable is set to true, then these temporary files will be preserved, otherwise they will be removed after the tool has exited. Defaults to false.

mergetool.prompt
Prompt before each invocation of the merge resolution program.