Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git mergetool fails

After a merge I want to use git mergetool to resolve the issue but it fails with whatever tool I specify:

git mergetool                                                                                                          
 merge tool candidates: opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 vimdiff emerge
Merging:
main.c

Normal merge conflict for 'main.c':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (kdiff3):
merge of main.c failed

The tool I specify doesn't seem to be launched at all.

Output of

git config --list

merge.tool=kdiff3
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
like image 817
Paul Praet Avatar asked Jun 21 '12 11:06

Paul Praet


People also ask

What is Mergetool in git?

Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file (skipping those without conflicts).

How do I quit git Mergetool?

How do I cancel a git merge? Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.

How do I change Mergetool?

git mergetool is fully configurable so you can pretty much chose your favourite tool. In brief, you can set a default mergetool by setting the user config variable merge. tool . If the merge tool is one of the ones supported natively by it you just have to set mergetool.


2 Answers

kdiff3 maybe not installed at your system. If it is, please, check if it is available through your PATH variable

Try

git config --global merge.tool <your_merge_program>

Also, you can specify your operating system and available merge programs

like image 172
Ribtoks Avatar answered Oct 07 '22 08:10

Ribtoks


Note that git 2.10 will offer a better exit status to identify diff/merge tool installation issue.

See commit 45a4f5d (15 Aug 2016) by John Keeping (johnkeeping).
(Merged by Junio C Hamano -- gitster -- in commit 331f06d, 19 Aug 2016)

difftool: always honor fatal error exit codes

At the moment difftool's "trust exit code" logic always suppresses the exit status of the diff utility we invoke.
This is useful because we don't want to exit just because diff returned "1" because the files differ, but it's confusing if the shell returns an error because the selected diff utility is not found.

POSIX specifies

  • 127 as the exit status for "command not found",
  • 126 for "command found but is not executable" and
  • values greater than 128 if the command terminated because it received a signal

At least bash and dash follow this specification, while diff utilities generally use "1" for the exit status we want to ignore.

Handle any value of 126 or greater as a special value indicating that some form of fatal error occurred.

like image 30
VonC Avatar answered Oct 07 '22 08:10

VonC