Git diff :: overriding.gitconfig external tool

I configured git to use meld as an external comparison tool:

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

... where git-meld :

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

However, sometimes (for example, in the case of very slight differences, or if I want to easily copy-paste something from the diff text), I just want to see the differences in the shell and avoid the meld delay.

Is there a way (like a command line argument) to override .gitconfig options and tell git just make a plain text diff?

+6
source share
2 answers

For your general question: almost all options can be overridden on the command line with -c :

-c <name> = <value>

Pass the configuration parameter to the command. The specified value overrides the values ​​from the configuration files. <name> is expected in the same format as specified in git config (dots-separated subkeys).

However, diff.external is a problem. You can change its value, but there is no way to disable it on the command line (what I see). However, git diff has a custom option to ignore the diff.external parameter: you can use

 git diff --no-ext-diff 
+15
source

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

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

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

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

You can also disable the prompt for git difftool by sending:

git config --global difftool.prompt false

+6
source

Source: https://habr.com/ru/post/957939/


All Articles