gitmergetool

Resolve conflicts automatically with git-mergetool


Now I resolve few conflicts, and want retain only remote state.

If I try change my option: git merge --strategy-option theirs
I have some errors: merge is not possible because you have unmerged files.

Of course, I can cancel my changes (for use command above), but then I will lose my changes.

Now, me offering run vimdiff:

  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (vimdiff):

How I can retain only remote state. If file not exist - it easy (offer push the button).


Solution

  • Use the git checkout command to set the working tree to match the remote stage (3):

    git checkout -3 PATHS...
    

    Or the local stage (2):

    git checkout -2 PATHS...
    

    Then add the files and commit to complete the merge.

    Use git checkout -h if you forget which one is 2 and 3.