From Electron Cloud
Jump to: navigation, search
(Created page with '<code>cp</code> can be added as a "merge tool" which you can use selectively to accept one side or the other of merge conflicts automatically, without having to run a visual diff…')
(No difference)

Revision as of 02:19, 20 October 2011

cp can be added as a "merge tool" which you can use selectively to accept one side or the other of merge conflicts automatically, without having to run a visual diff. (But it's a good idea to run visual diff or regular diff first to make sure whether you want the "local" or "remote" version!) Seems that so far in such cases I always want the "remote" version (in other words, the second version in the diff, or the non-HEAD version), so I just add cp in that direction as a "merge tool":

git config --global mergetool.accept-remote.cmd 'cp $REMOTE $MERGED'
git config --global mergetool.diffmerge.trustExitCode true

Usage:

git mergetool --tool=accept-remote [file ...]

and it will interact with you, something like this:

# git mergetool --tool=accept-remote
Merging:
file1.c
file2.h

Normal merge conflict for 'file1.c':
  {local}: modified
  {remote}: modified
Hit return to start merge resolution tool (accept-remote): 

...

and so on for each file to be merged.