Git mergetool: Source merging is inevitable with concurrent development. To help with merges, source control products have a merge tool. Some, including Git, allow configuring your favorite merge tool vs forcing use of their own merge tool.
Built-In Merge Tool Configuration
Git supports the easy configuration of many merge tools. The Git help lists them, and as of this writing they are:
To configure the git merge tool, use:
git config merge.tool
One of my favorite merge tools is by Perforce: P4Merge. It’s free to use, and does not require using the Perforce server or a license, so anyone can use it.
As an example, to configure it globally for all Git repos, execute:
git config --global merge.tool p4merge
Other Merge Tools
When specifying a merge.tool value not in the supported list, also specify a mergetool.<tool>.cmd matching variable. The value of this variable is the command to invoke the merge tool (may specify a script for ease).
In the process spawned to run the specified merge command, Git creates BASE, LOCAL, REMOTE, and MERGED environment variables. Use these variables in the launch of the merge tool.
git config --global merge.tool myfavtool git config --global mergetool.myfavtool.cmd myfavtool_executable $BASE $LOCAL $REMOTE $MERGED
Diff Tool Different from Merge Tool
To configure the diff tool Git uses different from the merge tool, similarly configure with the diff.tool setting:
git config --global diff.tool p4merge
Git has additional mergetool config variables. Consult the Git help for config to see them:
git help config