Git
简体中文 ▾ Topics ▾ Latest version ▾ git-difftool last updated in 2.44.0

名称

git-difftool - 使用常见的差异工具显示变化

概述

git difftool [<选项>] [<提交> [<提交>]] [--] [<路径>…​]

描述

git difftool is a Git command that allows you to compare and edit files between revisions using common diff tools. git difftool is a frontend to git diff and accepts the same options and arguments. See git-diff[1].

选项

-d
--dir-diff

把修改过的文件复制到一个临时位置,然后对它们进行目录比较。这种模式在启动差异工具之前从不提示。

-y
--no-prompt

在启动差异工具之前不要提示。

--prompt

Prompt before each invocation of the diff tool. This is the default behaviour; the option is provided to override any configuration settings.

--rotate-to=<文件>

开始显示给定路径的差异,在它之前的路径将移动到终点并输出。

--skip-to=<文件>

开始显示给定路径的差异,跳过前面所有的路径。

-t <工具>
--tool=<工具>

Use the diff tool specified by <tool>. Valid values include emerge, kompare, meld, and vimdiff. Run git difftool --tool-help for the list of valid <tool> settings.

If a diff tool is not specified, git difftool will use the configuration variable diff.tool. If the configuration variable diff.tool is not set, git difftool will pick a suitable default.

你可以通过设置配置变量 difftool.<工具>.path 来明确提供工具的完整路径。例如,你可以通过设置 difftool.kdiff3.path 来配置 kdiff3 的绝对路径。否则,git difftool 会假定该工具在 PATH 中可用。

通过在配置变量 difftool.<工具>.cmd 中指定要调用的命令行,可以定制 git difftool,而不是运行一个已知的比较工具,以运行一个替代程序。

When git difftool is invoked with this tool (either through the -t or --tool option or the diff.tool configuration variable) the configured command line will be invoked with the following variables available: $LOCAL is set to the name of the temporary file containing the contents of the diff pre-image and $REMOTE is set to the name of the temporary file containing the contents of the diff post-image. $MERGED is the name of the file which is being compared. $BASE is provided for compatibility with custom merge tool commands and has the same value as $MERGED.

--tool-help

列出可以和"--tool"命令一起使用的diff工具。

--dir-diff 模式下运行时,git difftool 的默认行为是创建指向工作目录树的符号链接,比较的右侧结果与工作目录树中的文件内容相同。

Specifying --no-symlinks instructs git difftool to create copies instead. --no-symlinks is the default on Windows.

-x <命令>
--extcmd=<命令>

Specify a custom command for viewing diffs. git-difftool ignores the configured defaults and runs <command> $LOCAL $REMOTE when this option is specified. Additionally, $BASE is set in the environment.

-g
--[no-]gui

当使用 -g--gui 选项调用 git-difftool 时,默认的差异工具将从配置的 diff.guitool 变量中读取,而不是 diff.tool。这可以通过配置变量 difftool.guiDefault 自动选择。可以使用 --no-gui 选项来覆盖这些设置。如果未设置 diff.guitool,我们将按照 merge.guitool, diff.tool, merge.tool 的顺序进行回退,直到找到工具为止。

--[no-]trust-exit-code

git-difftool invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use --trust-exit-code to make git-difftool exit when an invoked diff tool returns a non-zero exit code.

git-difftool 在使用 --trust-exit-code 时将转发被调用工具的退出代码。

关于支持的选项的完整列表,见 git-diff[1]

配置

当差异工具等价物没有被定义时,git difftool 会返回到 git mergetool 配置变量。

Warning

Missing zh_HANS-CN/includes/cmd-config-section-rest.txt

See original version for this content.

Warning

Missing zh_HANS-CN/config/difftool.txt

See original version for this content.

参见

git-diff[1]

显示提交之间的变化,提交和工作区,等等

git-mergetool[1]

运行合并冲突解决工具来解决合并冲突

git-config[1]

获取和设置仓库或全局选项

GIT

属于 git[1] 文档

scroll-to-top