简体   繁体   中英

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.

  3. feature/one was updated, lets say edited 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.

     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

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 ======

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?

you just have a normal merge conflict. Try out a few merge tools and then configure Git to use one you feel comfortable with. REMOTE,ORIG, LOCAL are the temp files corresponding to the "theirs", "merge-base", and "yours" version of the files. I don't recommend manually editing merge conflict markers for anything but the most trivial of merges.

Then adjust the following git config settings

trustExitCode - usually true

keepBackup - false

keepTemporaries - false

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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