git-mergetool
will normally automatically stage files after the conflicts have been resolved. You will not need to manually run git-add
.
However, in order to work with a variety of tools, git-mergetool
will try to verify that the file has been updated (see check_unchanged()) by checking the modification date. If the file has been modified, then, it will check the return code from the mergetool.
Some mergetools may not return the correct exit code (0 if the merge 'succeeded'), and so git also provides a configuration option mergetool.<tool>.trustExitCode
in case this should not be trusted. If this is set to false
, then git will always ask you if the merge was successful.
In summary:
- Your mergetool should save the file to disk after merging, even if no changes are necessary (which shouldn't be possible, since it wouldn't be a merge conflict).
- If you don't trust the exit code of your mergetool, you can set the
trustExitCode
option to false.
In practice, I recommend using one of the merge utilities that git now natively supports. You can get a list of these here. If you use one of these tools, you should not need any additional setup beyond configuring git to use it, e.g.:
git config --global merge.tool p4merge
Note: You may find a lot of outdated articles around the web about setup for these tools. My favorite mergetool, p4merge, for example, was not natively supported by git at first, and required some manual configuration. This is no longer necessary for recent versions of git.