简体   繁体   English

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

[英]How to merge changes with develop branch down to a feature branch

Situation 情况

  1. git branch
    • master
    • develop 开发
    • feature/one 功能/一个
    • feature/two 功能/两个
  2. feature/one and feature/two are identical, branched out from develop so develop branch is also identical with the feature branches. feature/onefeature/two是相同的,是从develop分支出来的,因此develop分支也与功能分支相同。

  3. feature/one was updated, lets say edited foo.css feature/one已更新,可以说已编辑foo.css

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

  5. feature/two was updated too, and forgot to merge from develop branch before updating, add a couple of files, and also added some css to foo.css too. feature/two也进行了更新,并且忘记了在更新之前从foo.css分支进行合并,添加了两个文件,并且还为foo.css添加了一些CSS。

     body { height: 100%; } .bar { color: #000; } 
  6. Now, I haven't staged anything from feature/two , because I know when I stage and commit it, if I do git add --all && git commit -m "some commit message" && git merge develop , I will have conflicts on foo.bar 现在,我还没有上演来自feature/two任何事情,因为我知道我上演并提交它的时间,如果我执行git add --all && git commit -m "some commit message" && git merge develop ,我将有冲突在foo.bar

Question

What kind of situation is this, I am trying to avoind file conflicts, because it doesn't feel right, and when I do git mergetool , it creates additional files, like REMOTE, ORIG, LOCAL, and I have a hard time understanding what are those, but I know, that I should decide which line of code should be persisted by editing the lines between <<<<< and ====== 这是什么情况,我试图避免文件冲突,因为它感觉不正确,并且当我执行git mergetool ,它会创建其他文件,例如REMOTE,ORIG,LOCAL,并且我很难理解是那些,但是我知道,我应该通过编辑<<<<<======之间的行来决定应保留哪行代码

I know this is pretty much a generic situation, where feature branches doesn't know that there are changes on develop branch beforehand, therefore they won't be able to merge first before editing, OR maybe is it really part of the workflow to merge from develop branch first before doing anything on the feature branch? 我知道这几乎是一种普遍情况,要素分支不知道事前对develop分支进行了更改,因此它们在编辑之前将无法首先合并,或者合并确实是工作流程的一部分在功能分支上执行任何操作之前先从develop分支开始吗?

you just have a normal merge conflict. 您只是有正常的合并冲突。 Try out a few merge tools and then configure Git to use one you feel comfortable with. 试用一些合并工具,然后将Git配置为使用您喜欢的工具。 REMOTE,ORIG, LOCAL are the temp files corresponding to the "theirs", "merge-base", and "yours" version of the files. REMOTE,ORIG,LOCAL是与文件的“其”,“合并基础”和“您的”版本相对应的临时文件。 I don't recommend manually editing merge conflict markers for anything but the most trivial of merges. 除了最琐碎的合并,我不建议手动编辑任何合并冲突标记。

Then adjust the following git config settings 然后调整以下git配置设置

trustExitCode - usually true trustExitCode-通常为true

keepBackup - false keepBackup-假

keepTemporaries - false keepTemporaries-错误

prompt - 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.

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

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