If you have your own merge tool that you would like to use, such as Kaleidoscope or p4merge, you can configure ungit to use it by following these steps:
- Configuring git
The first step is to configure git so that it knows how to invoke your merge tool. In your home directory, open (or create) the git configuration file .gitconfig. In this file, you will want to add information about your merge tool, it should look something like this:
[mergetool "extMerge"]
cmd = extMergeTool "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
trustExitCode = false
"extMergeTool"
is the merge tool you are invoking. This assumes your merge tool was installed and the command is recognized by your system. You may also replace this with the path to your merge tool directly.- For best results, refer to the documentation of your merge tool, as it may require different command arguments.
- The name
"extMerge"
can be whatever you want. I recommend that it not contain spaces or special symbols, as it may interfere when used as a command argument. "trustExitCode"
depends on the merge tool you are using. Iftrue
, git will use the return code of your merge tool to determine whether the conflict has been resolved, otherwise it will use the timestamp of the file to determine this (meaning if your merge tool saved over the file, it will assume it has been resolved).- Additionally, you can also provide the following if you want to identify your merge tool as the default:
[merge]
tool = extMerge
If you wish to test your configuration, open a console in a git repo that is currently waiting for conflict resolution and type the following command:
> git mergetool --tool extMerge
This should invoke your merge tool and cycle through each conflicted file.
- Configuring ungit
Add the "mergeTool"
option to your ungit configuration file (.ungitrc). Set this value to true
if you have configured a default merge tool with git, otherwise use the name of the merge tool you have configured (for example "extMerge"
). It should look something like this:
{
"mergeTool": "extMerge"
}
- Use ungit's interface
Start ungit and navigate to a repo with conflicted files. Now when you hover over the Conflicts
label displayed on one of the conflicted files, it should expand and give you an option to Launch Merge Tool
.
Once you have used your merge tool to resolve the conflicts, if ungit does not immediately recognize this, you may use the Mark as Resolved
button to manually tell git that the file is now resolved.
- Known Issues and Troubleshooting
- In some cases, your merge tool may take a few seconds to launch. Pressing the launch button multiple times will cause your merge tool to launch that many copies.
- Some merge tools (like
vimdiff
) are terminal-only tools and will not work with ungit. Your merge tool must work in a windowed environment. See the suggested merge tool section below. - If for any reason git does not recognize that your merge tool has resolved the file,
trustExitCode
may need to be set tofalse
. - When your merge tool is launched, four auto-generated files will appear. If you have
trustExitCode
set tofalse
and you cancel the merge tool, it may leave the generated files there. In this case, it is safe to manually remove them.
- Merge Tool Suggestions
- Mac OS X:
- Meld: meldmerge.org
- Kaleidoscope: kaleidoscopeapp.com
- Araxis Merge: araxis.com
- DeltaWalker: deltopia.com
- Windows:
- Beyond Compare: scootersoftware.com
- Araxis Merge: araxis.com
- P4Merge: perforce.com