I have configured Sourcegear DiffMerge to be my default git merge tool using the following instructions:
git config --global diff.tool diffmerge
git config --glo
It is possible that there will be no $BASE
file, if for instance the two files being merged have no common ancestor, or if you happen to get the conflict when applying or rebasing a patch rather than merging branches. In this case, while the $BASE
variable will still be set, there will be no file there.
In your mergetool command, you need to check whether $BASE
exists, and do a merge without a common ancestor if it does not. It doesn't look like DiffMerge supports that mode (it supports merging two files with no common ancestor, but it always writes the output to one of the files, not a result file). Instead, you'll need instead to pass in $LOCAL
as the $BASE
file if $BASE
does not exist:
git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'