why doesn't my .gitconfig work? (for external diff)
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).
Related videos on Youtube
Skyler
I have discovered a truly marvelous proof of myself, which this margin is too narrow to contain.
Updated on September 18, 2022Comments
-
Skyler over 1 year
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 normaldiff
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.
-
ihadanny almost 11 yearsstill 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....