10

I'm trying to use gvimdiff as a mergetool for git on Windows. Previously I've used vimdiff in console mode, but know feel like I'm not happy with limiting view Windows console size, so I'm trying to switch to gvimdiff which have more flexible approach to setting window size.

But trying to call git mergetool now I'm receiving error which is not clear for me:

The merge tool gvimdiff is not available as 'gvim'

How this could be resolved?

gvim for Windows is install and accessible via command line. The same is true for gvimdiff command.

I'm trying to find the place where this error is raised in git scripts, but currently with no luck.

shytikov
  • 9,155
  • 8
  • 56
  • 103
  • A side note: you can change `cmd`'s default size by right clicking on the top-bar -> properties and something there. While you are there, you can also tell it to initialize every window at the same starting position. Then once you click ok, it asks if you want to set it as default or only for this window. – Shahbaz Jun 14 '12 at 09:05
  • It does not help for me in this particular case... the code I'm trying to merge have huge indentations and length of the lines, so I plan gain some more pixels (g) by setting small but readable font in gvimdiff... – shytikov Jun 14 '12 at 09:08
  • 1
    The error is raised in the `get_merge_tool_path` function inside `$(git --exec-path)\git-mergetool--lib`. When you configure `gvimdiff `as your merge tool, git internally translates that to a `gvim` command (see `$(git --exec-path)\mergetools\vim`. From the shell that you launch `git mergetool`, you must be able to run `gvim`. If that works, then `git mergetool` should as well. – Tim Henigan Jun 14 '12 at 12:57
  • @TimHenigan I'm afraid your comment is necessarily wrong because I can run gvim and vim from the Cmder console but I get the same error when I run `git mergetool`. Regretfully, I still don't know why. – Hovis Biddle Jul 26 '16 at 04:37

2 Answers2

9

If you start a Git console, are you sure the commands are accessible? I'm suspecting that it is not on the PATH of your Git console, only the Windows PATH (which is not entirely included).

rlegendi
  • 10,466
  • 3
  • 38
  • 50
  • 1
    He is opening a GVim window, not a console. Although git console not grabbing PATH is annoying as hell – Shahbaz Jun 14 '12 at 09:13
  • @Shahbaz: Actually `git` is attempting to open the `gvim`, not the user. To test that PATH is set up properly, the user must check if he can execute `gvim` from the same shell that he is running `git mergetool`. – Tim Henigan Jun 14 '12 at 13:01
  • 4
    You're right the Windows PATH variable was omitted. I didn't know how to add it to the msysgit environment, so I've just created file `c:\Program Files (x86)\Git\bin\gvim` with following contents: #!/bin/sh exec "/c/Program Files (x86)/Vim/vim73/gvim.exe" "$@" And it worked! – shytikov Jun 14 '12 at 16:28
  • Yeah, glad to hear it helped. – rlegendi Jun 14 '12 at 19:41
  • 1
    I combined this answer and one below to create /usr/local/bin/gvimdiff `#!/bin/bash` `/c/PROGRA~2/Vim/vim74/gvim -d "${LOCAL}" "${REMOTE}"` – Jessica Pennell Jun 28 '17 at 18:07
3

Combining your answers, these are my settings

.gitconfig

[alias]
    d = difftool
[diff]
    renames = copy
    tool = gvimdiff
[difftool "gvimdiff"]
    cmd = "gvim -d" "$LOCAL" "$REMOTE"
[difftool]
    prompt = false

And added file gvim accessible in %PATH% with content:

"C:\Program Files (x86)\Vim\vim73\gvim.exe" "$@"

Git difftool in Windows to see list of all changed files in addition to file diffs (a la Kaleidoscope)?

rofrol
  • 14,438
  • 7
  • 79
  • 77