Question

I've configured git to use meld as an external diff tool:

$ cat ~/.gitconfig | grep -A2 "\[diff\]"
[diff]
        tool = vimdiff
        external = git-meld

... where git-meld is:

$ cat $(which git-meld)
#!/bin/bash
meld $2 $5

However sometimes (e.g. in the case of very minor diffs or if I want to easily copy-paste something from the diff text) I just want to see the differences on the shell and avoid meld's spawning delay.

Is there a way (e.g. a command line argument) to override the .gitconfig settings and instruct git to just do a simple text-only diff?

Was it helpful?

Solution

For your general question: pretty much all options can be overridden on the command line using -c:

-c <name>=<value>

Pass a configuration parameter to the command. The value given will override values from configuration files. The <name> is expected in the same format as listed by git config (subkeys separated by dots).

That said, diff.external is a problem. You can change its value, but there is no way to unset it on the command line (that I can see). However, git diff does have a custom option to ignore the diff.external setting: you can use

git diff --no-ext-diff

OTHER TIPS

Another option is to use git difftool, which is just like git diff but always uses a GUI tool (and by default prompts you for one).

When you use git diff, git uses the tool specified in diff.external.

When you use git difftool, git uses the tool in specified in diff.tool.

What I like to do is leave diff.external unset, and then use git difftool when I want a GUI diff, and just git diff when I don't.

You can also turn the prompt off for git difftool by sending:

git config --global difftool.prompt false

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top