I wanted to use the great Araxis Merge tool as a helper to solve merge conflicts with Git but currently it is not supported out-of-the-box. Luckily new commands can be configured by hand but a quick Google search didn’t turn up anything I could have simply copy-pasted to get it working. So here goes..
I assume that you’ve got Araxis Merge installed including the binaries that are located in the “Utilities” directory in the distribution. It doesn’t matter where you place the binaries as long as they are available. I put them under /usr/local/bin on my Mac.
In case of a merge conflict there are two possible scenarios: one, in which a common base version exists and second, where it does not exist. These scenarios require the use of a three-way-diff or a two-way-diff operation, respectively. The command line options for Araxis Merge require that we know in advance which scenario we are facing so I had to resolve to using a simple shell script wrapper that would make the appropriate call to the compare binary. The shell script I used is below.
#!/usr/bin/env bash LOCAL=$1 REMOTE=$2 MERGED=$3 BASE=$4 MERGE=/usr/local/bin/compare if [ -e "$BASE" ]; then $MERGE -wait -merge -3 -a1 \ -title1:"$MERGED (Base)" \ -title2:"$MERGED (Local)" \ -title3:"$MERGED (Remote)" \ "$BASE" "$LOCAL" "$REMOTE" "$MERGED" else $MERGE -wait -2 \ -title1:"$MERGED (Local)" \ -title2:"$MERGED (Remote)" \ "$LOCAL" "$REMOTE" "$MERGED" fi
To get it working I saved the shell script in /usr/local/bin/araxis-mergetool, made it executable and configured Git as follows
git config --global mergetool.araxis.cmd \ 'araxis-mergetool "$LOCAL" "$REMOTE" "$MERGED" "$BASE"' git config --global merge.tool araxis
Now, when I get merge conflicts I can run git mergetool and Araxis Merge will be opened up in the proper mode with the conflicting files.
Unfortunately Araxis Merge and the compare binary do not appear to set the exit code of the process in a manner that Git would understand so after fixing up the conflict I may still need to tell Git whether the merge was successful or not.