Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

migrated from stackoverflow.com Nov 16 '12 at 20:13

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

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).

share|improve this answer
    
Thank you sir! Prob solved. –  Skyler Nov 18 '12 at 1:17
    
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 May 13 '13 at 8:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.