11

我已配置gitmeld用作外部差异工具:

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

...在哪里git-meld

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

但是有时(例如,在非常小的差异的情况下,或者如果我想轻松地从差异文本中复制粘贴某些内容)我只想查看 shell 上的差异并避免meld产生延迟。

有没有办法(例如命令行参数)来覆盖.gitconfig设置并指示git只做一个简单的纯文本差异?

4

2 回答 2

22

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
于 2013-11-12T17:58:23.337 回答
8

另一种选择是使用git difftool,这就像git diff但始终使用 GUI 工具(默认情况下会提示您使用)。

使用时git diff,git 使用diff.external.

使用时git difftool,git 使用 中指定的工具diff.tool

我喜欢做的是保持未diff.external 设置,然后git difftool在我想要 GUI 差异时使用,而git diff在我不需要时使用。

git difftool您还可以通过发送关闭提示:

git config --global difftool.prompt false

于 2014-07-07T14:05:48.907 回答