why doesn't my .gitconfig work? (for external diff)

3

0

I added this in ~/.gitconfig:

[diff]
    external = mvimdiff

[difftool]
    prompt = false

and made a 755 /bin/mvimdiff that:

#!/bin/sh

mvim -d "$2" "$5"

in order to invoke MacVim as my git diff tool. But when I run command git diff in a git folder, it still output the result from normal diff to shell. No MacVim at all. I am sure that no .git/config overwrite the .gitconfig, and I have tried to restart my computer to refresh. Why doesn't the config work?

Thank you.

Skyler

Posted 2012-11-16T14:31:57.737

Reputation: 185

Answers

4

You may be better off using git difftool to invoke an “interactive” diff tool. For example:

Adapt the built-in gvimdiff tool to mvim:

git config --global diff.tool gvimdiff
git config --global difftool.gvimdiff.path mvim

Or, configure mvimdiff from scratch:

git config --global diff.tool mvimdiff
git config --global difftool.mvimdiff.cmd 'mvim -f -d "$LOCAL" "$REMOTE"'

Then run git difftool to view the each differing file in MacVim.


If you really want git diff itself to use MacVim, then you can configure it like this (without any external script files):

git config diff.external 'd() { mvim -f -d "$2" "$5"; }; d'

Either way, you need to make sure that the appropriate mvim is in your PATH. Also, you will need to use the -f option (“do not fork”/“run in foreground”) because otherwise git diff will probably delete the temporary files before MacVim has had a chance to read them (at least one file from each invocation will be a temporary file).

Chris Johnsen

Posted 2012-11-16T14:31:57.737

Reputation: 31 786

still doesn't work for me :(➜

✗ git config --global diff.tool meld ✗ git config --global difftool.meld.cmd 'meld "$LOCAL" "$REMOTE"' ✗ git difftool env-context.xml diff --cc env-context.xml index 4f430b5,b7ab2ef..0000000.... – ihadanny – 2013-05-13T08:42:58.900