<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect2 SYSTEM "../../../dtd/dblite.dtd">

<sect2 lang="en" id="git-difftool(1)">
    <title>git-difftool(1)</title>
    <date>2024-07-02</date>
<revhistory><revision><date>2024-07-02</date></revision></revhistory>
<indexterm>
<primary>git-difftool(1)</primary>
</indexterm>
<simplesect id="git-difftool(1)__name">
<title>NAME</title>
<simpara>git-difftool - Show changes using common diff tools</simpara>
</simplesect>
<simplesect id="git-difftool(1)__synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git difftool</emphasis> [&lt;options&gt;] [&lt;commit&gt; [&lt;commit&gt;]] [--] [&lt;path&gt;&#8230;]</literallayout>
</blockquote>
</simplesect>
<simplesect id="git-difftool(1)__description">
<title>DESCRIPTION</title>
<simpara><emphasis>git difftool</emphasis> is a Git command that allows you to compare and edit files
between revisions using common diff tools.  <emphasis>git difftool</emphasis> is a frontend
to <emphasis>git diff</emphasis> and accepts the same options and arguments. See
<xref linkend="git-diff(1)" />.</simpara>
</simplesect>
<simplesect id="git-difftool(1)__options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
-d
</term>
<term>
--dir-diff
</term>
<listitem>
<simpara>
        Copy the modified files to a temporary location and perform
        a directory diff on them. This mode never prompts before
        launching the diff tool.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-y
</term>
<term>
--no-prompt
</term>
<listitem>
<simpara>
        Do not prompt before launching a diff tool.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--prompt
</term>
<listitem>
<simpara>
        Prompt before each invocation of the diff tool.
        This is the default behaviour; the option is provided to
        override any configuration settings.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--rotate-to=&lt;file&gt;
</term>
<listitem>
<simpara>
        Start showing the diff for the given path,
        the paths before it will move to the end and output.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--skip-to=&lt;file&gt;
</term>
<listitem>
<simpara>
        Start showing the diff for the given path, skipping all
        the paths before it.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-t &lt;tool&gt;
</term>
<term>
--tool=&lt;tool&gt;
</term>
<listitem>
<simpara>
        Use the diff tool specified by &lt;tool&gt;.  Valid values include
        emerge, kompare, meld, and vimdiff. Run <emphasis>git difftool --tool-help</emphasis>
        for the list of valid &lt;tool&gt; settings.
</simpara>
<simpara>If a diff tool is not specified, <emphasis>git difftool</emphasis>
will use the configuration variable <emphasis>diff.tool</emphasis>.  If the
configuration variable <emphasis>diff.tool</emphasis> is not set, <emphasis>git difftool</emphasis>
will pick a suitable default.</simpara>
<simpara>You can explicitly provide a full path to the tool by setting the
configuration variable <emphasis>difftool.&lt;tool&gt;.path</emphasis>. For example, you
can configure the absolute path to kdiff3 by setting
<emphasis>difftool.kdiff3.path</emphasis>. Otherwise, <emphasis>git difftool</emphasis> assumes the
tool is available in PATH.</simpara>
<simpara>Instead of running one of the known diff tools,
<emphasis>git difftool</emphasis> can be customized to run an alternative program
by specifying the command line to invoke in a configuration
variable <emphasis>difftool.&lt;tool&gt;.cmd</emphasis>.</simpara>
<simpara>When <emphasis>git difftool</emphasis> is invoked with this tool (either through the
<emphasis>-t</emphasis> or <emphasis>--tool</emphasis> option or the <emphasis>diff.tool</emphasis> configuration variable)
the configured command line will be invoked with the following
variables available: <emphasis>$LOCAL</emphasis> is set to the name of the temporary
file containing the contents of the diff pre-image and <emphasis>$REMOTE</emphasis>
is set to the name of the temporary file containing the contents
of the diff post-image.  <emphasis>$MERGED</emphasis> is the name of the file which is
being compared. <emphasis>$BASE</emphasis> is provided for compatibility
with custom merge tool commands and has the same value as <emphasis>$MERGED</emphasis>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--tool-help
</term>
<listitem>
<simpara>
        Print a list of diff tools that may be used with <emphasis>--tool</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--[no-]symlinks
</term>
<listitem>
<simpara>
        <emphasis>git difftool</emphasis>'s default behavior is to create symlinks to the
        working tree when run in <emphasis>--dir-diff</emphasis> mode and the right-hand
        side of the comparison yields the same content as the file in
        the working tree.
</simpara>
<simpara>Specifying <emphasis>--no-symlinks</emphasis> instructs <emphasis>git difftool</emphasis> to create copies
instead.  <emphasis>--no-symlinks</emphasis> is the default on Windows.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-x &lt;command&gt;
</term>
<term>
--extcmd=&lt;command&gt;
</term>
<listitem>
<simpara>
        Specify a custom command for viewing diffs.
        <emphasis>git-difftool</emphasis> ignores the configured defaults and runs
        <emphasis>&lt;command&gt; $LOCAL $REMOTE</emphasis> when this option is specified.
        Additionally, <emphasis>$BASE</emphasis> is set in the environment.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-g
</term>
<term>
--[no-]gui
</term>
<listitem>
<simpara>
        When <emphasis>git-difftool</emphasis> is invoked with the <emphasis>-g</emphasis> or <emphasis>--gui</emphasis> option
        the default diff tool will be read from the configured
        <emphasis>diff.guitool</emphasis> variable instead of <emphasis>diff.tool</emphasis>. This may be
        selected automatically using the configuration variable
        <emphasis>difftool.guiDefault</emphasis>. The <emphasis>--no-gui</emphasis> option can be used to
        override these settings. If <emphasis>diff.guitool</emphasis> is not set, we will
        fallback in the order of <emphasis>merge.guitool</emphasis>, <emphasis>diff.tool</emphasis>,
        <emphasis>merge.tool</emphasis> until a tool is found.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--[no-]trust-exit-code
</term>
<listitem>
<simpara>
        Errors reported by the diff tool are ignored by default.
        Use <emphasis>--trust-exit-code</emphasis> to make <emphasis>git-difftool</emphasis> exit when an
        invoked diff tool returns a non-zero exit code.
</simpara>
<simpara><emphasis>git-difftool</emphasis> will forward the exit code of the invoked tool when
<emphasis>--trust-exit-code</emphasis> is used.</simpara>
</listitem>
</varlistentry>
</variablelist>
<simpara>See <xref linkend="git-diff(1)" /> for the full list of supported options.</simpara>
</simplesect>
<simplesect id="git-difftool(1)__configuration">
<title>CONFIGURATION</title>
<simpara><emphasis>git difftool</emphasis> falls back to <emphasis>git mergetool</emphasis> config variables when the
difftool equivalents have not been defined.</simpara>
<simpara>Everything above this line in this section isn't included from the
<xref linkend="git-config(1)" /> documentation. The content that follows is the
same as what's found there:</simpara>
<variablelist>
<varlistentry>
<term>
diff.tool
</term>
<listitem>
<simpara>
        Controls which diff tool is used by <xref linkend="git-difftool(1)" />.
        This variable overrides the value configured in <emphasis>merge.tool</emphasis>.
        The list below shows the valid built-in values.
        Any other value is treated as a custom diff tool and requires
        that a corresponding difftool.&lt;tool&gt;.cmd variable is defined.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
diff.guitool
</term>
<listitem>
<simpara>
        Controls which diff tool is used by <xref linkend="git-difftool(1)" /> when
        the -g/--gui flag is specified. This variable overrides the value
        configured in <emphasis>merge.guitool</emphasis>. The list below shows the valid
        built-in values. Any other value is treated as a custom diff tool
        and requires that a corresponding difftool.&lt;guitool&gt;.cmd variable
        is defined.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
difftool.&lt;tool&gt;.cmd
</term>
<listitem>
<simpara>
        Specify the command to invoke the specified diff tool.
        The specified command is evaluated in shell with the following
        variables available:  <emphasis>LOCAL</emphasis> is set to the name of the temporary
        file containing the contents of the diff pre-image and <emphasis>REMOTE</emphasis>
        is set to the name of the temporary file containing the contents
        of the diff post-image.
</simpara>
<simpara>See the <emphasis>--tool=&lt;tool&gt;</emphasis> option in <xref linkend="git-difftool(1)" /> for more details.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
difftool.&lt;tool&gt;.path
</term>
<listitem>
<simpara>
        Override the path for the given tool.  This is useful in case
        your tool is not in the PATH.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
difftool.trustExitCode
</term>
<listitem>
<simpara>
        Exit difftool if the invoked diff tool returns a non-zero exit status.
</simpara>
<simpara>See the <emphasis>--trust-exit-code</emphasis> option in <xref linkend="git-difftool(1)" /> for more details.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
difftool.prompt
</term>
<listitem>
<simpara>
        Prompt before each invocation of the diff tool.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
difftool.guiDefault
</term>
<listitem>
<simpara>
        Set <emphasis>true</emphasis> to use the <emphasis>diff.guitool</emphasis> by default (equivalent to specifying
        the <emphasis>--gui</emphasis> argument), or <emphasis>auto</emphasis> to select <emphasis>diff.guitool</emphasis> or <emphasis>diff.tool</emphasis>
        depending on the presence of a <emphasis>DISPLAY</emphasis> environment variable value. The
        default is <emphasis>false</emphasis>, where the <emphasis>--gui</emphasis> argument must be provided
        explicitly for the <emphasis>diff.guitool</emphasis> to be used.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-difftool(1)__see_also">
<title>SEE ALSO</title>
<variablelist>
<varlistentry>
<term>
<xref linkend="git-diff(1)" />
</term>
<listitem>
<simpara>
         Show changes between commits, commit and working tree, etc
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<xref linkend="git-mergetool(1)" />
</term>
<listitem>
<simpara>
        Run merge conflict resolution tools to resolve merge conflicts
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<xref linkend="git-config(1)" />
</term>
<listitem>
<simpara>
         Get and set repository or global options
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-difftool(1)__git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
</simplesect>
</sect2>
