GitMergetool

nicolaw 12th June 2018 at 1:11pm
Git

Getting git to run your diff and merge tools for you, instead of struggling with what compare, can save you immense amounts of time.

git merge another-branch
# there is a conflict, oh noes!
git mergetool
[diff]
  tool = bcomp

[difftool]
  prompt = false

[difftool "meld"]
  cmd = /Applications/Meld.app/Contents/MacOS/Meld \"$LOCAL\" \"$REMOTE\"

[difftool "bcomp"]
  cmd = bcomp \"$LOCAL\" \"$REMOTE\"

[difftool "sourcetree"]
  cmd = opendiff \"$LOCAL\" \"$REMOTE\"

[merge]
  tool = bcomp

[mergetool]
  prompt = false

[mergetool "meld"]
  trustExitCode = false
  cmd = /Applications/Meld.app/Contents/MacOS/Meld \"$LOCAL\" \"$MERGED\" \"$REMOTE\"--output=\"$MERGED\"

[mergetool "bcomp"]
  trustExitCode = false
  cmd = bcomp \"$LOCAL\" \"$REMOTE\" \"$MERGED\" \"$MERGED\"

[mergetool "sourcetree"]
  trustExitCode = false
  cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"