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

<sect2 lang="en" id="git-fetch(1)">
    <title>git-fetch(1)</title>
    <date>2024-07-02</date>
<revhistory><revision><date>2024-07-02</date></revision></revhistory>
<indexterm>
<primary>git-fetch(1)</primary>
</indexterm>
<simplesect id="git-fetch(1)__name">
<title>NAME</title>
<simpara>git-fetch - Download objects and refs from another repository</simpara>
</simplesect>
<simplesect id="git-fetch(1)__synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git fetch</emphasis> [&lt;options&gt;] [&lt;repository&gt; [&lt;refspec&gt;&#8230;]]
<emphasis>git fetch</emphasis> [&lt;options&gt;] &lt;group&gt;
<emphasis>git fetch</emphasis> --multiple [&lt;options&gt;] [(&lt;repository&gt; | &lt;group&gt;)&#8230;]
<emphasis>git fetch</emphasis> --all [&lt;options&gt;]</literallayout>
</blockquote>
</simplesect>
<simplesect id="git-fetch(1)__description">
<title>DESCRIPTION</title>
<simpara>Fetch branches and/or tags (collectively, "refs") from one or more
other repositories, along with the objects necessary to complete their
histories.  Remote-tracking branches are updated (see the description
of &lt;refspec&gt; below for ways to control this behavior).</simpara>
<simpara>By default, any tag that points into the histories being fetched is
also fetched; the effect is to fetch tags that
point at branches that you are interested in.  This default behavior
can be changed by using the --tags or --no-tags options or by
configuring remote.&lt;name&gt;.tagOpt.  By using a refspec that fetches tags
explicitly, you can fetch tags that do not point into branches you
are interested in as well.</simpara>
<simpara><emphasis>git fetch</emphasis> can fetch from either a single named repository or URL,
or from several repositories at once if &lt;group&gt; is given and
there is a remotes.&lt;group&gt; entry in the configuration file.
(See <xref linkend="git-config(1)" />).</simpara>
<simpara>When no remote is specified, by default the <emphasis>origin</emphasis> remote will be used,
unless there's an upstream branch configured for the current branch.</simpara>
<simpara>The names of refs that are fetched, together with the object names
they point at, are written to <emphasis>.git/FETCH_HEAD</emphasis>.  This information
may be used by scripts or other git commands, such as <xref linkend="git-pull(1)" />.</simpara>
</simplesect>
<simplesect id="git-fetch(1)__options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
--[no-]all
</term>
<listitem>
<simpara>
        Fetch all remotes. This overrides the configuration variable
        <emphasis>fetch.all</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-a
</term>
<term>
--append
</term>
<listitem>
<simpara>
        Append ref names and object names of fetched refs to the
        existing contents of <emphasis>.git/FETCH_HEAD</emphasis>.  Without this
        option old data in <emphasis>.git/FETCH_HEAD</emphasis> will be overwritten.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--atomic
</term>
<listitem>
<simpara>
        Use an atomic transaction to update local refs. Either all refs are
        updated, or on error, no refs are updated.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--depth=&lt;depth&gt;
</term>
<listitem>
<simpara>
        Limit fetching to the specified number of commits from the tip of
        each remote branch history. If fetching to a <emphasis>shallow</emphasis> repository
        created by <emphasis>git clone</emphasis> with <emphasis>--depth=&lt;depth&gt;</emphasis> option (see
        <xref linkend="git-clone(1)" />), deepen or shorten the history to the specified
        number of commits. Tags for the deepened commits are not fetched.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--deepen=&lt;depth&gt;
</term>
<listitem>
<simpara>
        Similar to --depth, except it specifies the number of commits
        from the current shallow boundary instead of from the tip of
        each remote branch history.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--shallow-since=&lt;date&gt;
</term>
<listitem>
<simpara>
        Deepen or shorten the history of a shallow repository to
        include all reachable commits after &lt;date&gt;.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--shallow-exclude=&lt;revision&gt;
</term>
<listitem>
<simpara>
        Deepen or shorten the history of a shallow repository to
        exclude commits reachable from a specified remote branch or tag.
        This option can be specified multiple times.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--unshallow
</term>
<listitem>
<simpara>
        If the source repository is complete, convert a shallow
        repository to a complete one, removing all the limitations
        imposed by shallow repositories.
</simpara>
<simpara>If the source repository is shallow, fetch as much as possible so that
the current repository has the same history as the source repository.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--update-shallow
</term>
<listitem>
<simpara>
        By default when fetching from a shallow repository,
        <emphasis>git fetch</emphasis> refuses refs that require updating
        .git/shallow. This option updates .git/shallow and accepts such
        refs.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--negotiation-tip=&lt;commit|glob&gt;
</term>
<listitem>
<simpara>
        By default, Git will report, to the server, commits reachable
        from all local refs to find common commits in an attempt to
        reduce the size of the to-be-received packfile. If specified,
        Git will only report commits reachable from the given tips.
        This is useful to speed up fetches when the user knows which
        local ref is likely to have commits in common with the
        upstream ref being fetched.
</simpara>
<simpara>This option may be specified more than once; if so, Git will report
commits reachable from any of the given commits.</simpara>
<simpara>The argument to this option may be a glob on ref names, a ref, or the (possibly
abbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying
this option multiple times, one for each matching ref name.</simpara>
<simpara>See also the <emphasis>fetch.negotiationAlgorithm</emphasis> and <emphasis>push.negotiate</emphasis>
configuration variables documented in <xref linkend="git-config(1)" />, and the
<emphasis>--negotiate-only</emphasis> option below.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--negotiate-only
</term>
<listitem>
<simpara>
        Do not fetch anything from the server, and instead print the
        ancestors of the provided <emphasis>--negotiation-tip=*</emphasis> arguments,
        which we have in common with the server.
</simpara>
<simpara>This is incompatible with <emphasis>--recurse-submodules=[yes|on-demand]</emphasis>.
Internally this is used to implement the <emphasis>push.negotiate</emphasis> option, see
<xref linkend="git-config(1)" />.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--dry-run
</term>
<listitem>
<simpara>
        Show what would be done, without making any changes.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--porcelain
</term>
<listitem>
<simpara>
        Print the output to standard output in an easy-to-parse format for
        scripts. See section OUTPUT in <xref linkend="git-fetch(1)" /> for details.
</simpara>
<simpara>This is incompatible with <emphasis>--recurse-submodules=[yes|on-demand]</emphasis> and takes
precedence over the <emphasis>fetch.output</emphasis> config option.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--[no-]write-fetch-head
</term>
<listitem>
<simpara>
        Write the list of remote refs fetched in the <emphasis>FETCH_HEAD</emphasis>
        file directly under <emphasis>$GIT_DIR</emphasis>.  This is the default.
        Passing <emphasis>--no-write-fetch-head</emphasis> from the command line tells
        Git not to write the file.  Under <emphasis>--dry-run</emphasis> option, the
        file is never written.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-f
</term>
<term>
--force
</term>
<listitem>
<simpara>
        When <emphasis>git fetch</emphasis> is used with <emphasis>&lt;src&gt;:&lt;dst&gt;</emphasis> refspec, it may
        refuse to update the local branch as discussed
        in the <emphasis>&lt;refspec&gt;</emphasis> part below.
        This option overrides that check.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-k
</term>
<term>
--keep
</term>
<listitem>
<simpara>
        Keep downloaded pack.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--multiple
</term>
<listitem>
<simpara>
        Allow several &lt;repository&gt; and &lt;group&gt; arguments to be
        specified. No &lt;refspec&gt;s may be specified.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--[no-]auto-maintenance
</term>
<term>
--[no-]auto-gc
</term>
<listitem>
<simpara>
        Run <emphasis>git maintenance run --auto</emphasis> at the end to perform automatic
        repository maintenance if needed. (<emphasis>--[no-]auto-gc</emphasis> is a synonym.)
        This is enabled by default.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--[no-]write-commit-graph
</term>
<listitem>
<simpara>
        Write a commit-graph after fetching. This overrides the config
        setting <emphasis>fetch.writeCommitGraph</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--prefetch
</term>
<listitem>
<simpara>
        Modify the configured refspec to place all refs into the
        <emphasis>refs/prefetch/</emphasis> namespace. See the <emphasis>prefetch</emphasis> task in
        <xref linkend="git-maintenance(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-p
</term>
<term>
--prune
</term>
<listitem>
<simpara>
        Before fetching, remove any remote-tracking references that no
        longer exist on the remote.  Tags are not subject to pruning
        if they are fetched only because of the default tag
        auto-following or due to a --tags option.  However, if tags
        are fetched due to an explicit refspec (either on the command
        line or in the remote configuration, for example if the remote
        was cloned with the --mirror option), then they are also
        subject to pruning. Supplying <emphasis>--prune-tags</emphasis> is a shorthand for
        providing the tag refspec.
</simpara>
<simpara>See the PRUNING section below for more details.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-P
</term>
<term>
--prune-tags
</term>
<listitem>
<simpara>
        Before fetching, remove any local tags that no longer exist on
        the remote if <emphasis>--prune</emphasis> is enabled. This option should be used
        more carefully, unlike <emphasis>--prune</emphasis> it will remove any local
        references (local tags) that have been created. This option is
        a shorthand for providing the explicit tag refspec along with
        <emphasis>--prune</emphasis>, see the discussion about that in its documentation.
</simpara>
<simpara>See the PRUNING section below for more details.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-n
</term>
<term>
--no-tags
</term>
<listitem>
<simpara>
        By default, tags that point at objects that are downloaded
        from the remote repository are fetched and stored locally.
        This option disables this automatic tag following. The default
        behavior for a remote may be specified with the remote.&lt;name&gt;.tagOpt
        setting. See <xref linkend="git-config(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--refetch
</term>
<listitem>
<simpara>
        Instead of negotiating with the server to avoid transferring commits and
        associated objects that are already present locally, this option fetches
        all objects as a fresh clone would. Use this to reapply a partial clone
        filter from configuration or using <emphasis>--filter=</emphasis> when the filter
        definition has changed. Automatic post-fetch maintenance will perform
        object database pack consolidation to remove any duplicate objects.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--refmap=&lt;refspec&gt;
</term>
<listitem>
<simpara>
        When fetching refs listed on the command line, use the
        specified refspec (can be given more than once) to map the
        refs to remote-tracking branches, instead of the values of
        <emphasis>remote.*.fetch</emphasis> configuration variables for the remote
        repository.  Providing an empty <emphasis>&lt;refspec&gt;</emphasis> to the
        <emphasis>--refmap</emphasis> option causes Git to ignore the configured
        refspecs and rely entirely on the refspecs supplied as
        command-line arguments. See section on "Configured Remote-tracking
        Branches" for details.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-t
</term>
<term>
--tags
</term>
<listitem>
<simpara>
        Fetch all tags from the remote (i.e., fetch remote tags
        <emphasis>refs/tags/*</emphasis> into local tags with the same name), in addition
        to whatever else would otherwise be fetched.  Using this
        option alone does not subject tags to pruning, even if --prune
        is used (though tags may be pruned anyway if they are also the
        destination of an explicit refspec; see <emphasis>--prune</emphasis>).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--recurse-submodules[=(yes|on-demand|no)]
</term>
<listitem>
<simpara>
        This option controls if and under what conditions new commits of
        submodules should be fetched too. When recursing through submodules,
        <emphasis>git fetch</emphasis> always attempts to fetch "changed" submodules, that is, a
        submodule that has commits that are referenced by a newly fetched
        superproject commit but are missing in the local submodule clone. A
        changed submodule can be fetched as long as it is present locally e.g.
        in <emphasis>$GIT_DIR/modules/</emphasis> (see <xref linkend="gitsubmodules(7)" />); if the upstream
        adds a new submodule, that submodule cannot be fetched until it is
        cloned e.g. by <emphasis>git submodule update</emphasis>.
</simpara>
<simpara>When set to <emphasis>on-demand</emphasis>, only changed submodules are fetched. When set
to <emphasis>yes</emphasis>, all populated submodules are fetched and submodules that are
both unpopulated and changed are fetched. When set to <emphasis>no</emphasis>, submodules
are never fetched.</simpara>
<simpara>When unspecified, this uses the value of <emphasis>fetch.recurseSubmodules</emphasis> if it
is set (see <xref linkend="git-config(1)" />), defaulting to <emphasis>on-demand</emphasis> if unset.
When this option is used without any value, it defaults to <emphasis>yes</emphasis>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-j
</term>
<term>
--jobs=&lt;n&gt;
</term>
<listitem>
<simpara>
        Number of parallel children to be used for all forms of fetching.
</simpara>
<simpara>If the <emphasis>--multiple</emphasis> option was specified, the different remotes will be fetched
in parallel. If multiple submodules are fetched, they will be fetched in
parallel. To control them independently, use the config settings
<emphasis>fetch.parallel</emphasis> and <emphasis>submodule.fetchJobs</emphasis> (see <xref linkend="git-config(1)" />).</simpara>
<simpara>Typically, parallel recursive and multi-remote fetches will be faster. By
default fetches are performed sequentially, not in parallel.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-recurse-submodules
</term>
<listitem>
<simpara>
        Disable recursive fetching of submodules (this has the same effect as
        using the <emphasis>--recurse-submodules=no</emphasis> option).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--set-upstream
</term>
<listitem>
<simpara>
        If the remote is fetched successfully, add upstream
        (tracking) reference, used by argument-less
        <xref linkend="git-pull(1)" /> and other commands. For more information,
        see <emphasis>branch.&lt;name&gt;.merge</emphasis> and <emphasis>branch.&lt;name&gt;.remote</emphasis> in
        <xref linkend="git-config(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--submodule-prefix=&lt;path&gt;
</term>
<listitem>
<simpara>
        Prepend &lt;path&gt; to paths printed in informative messages
        such as "Fetching submodule foo".  This option is used
        internally when recursing over submodules.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--recurse-submodules-default=[yes|on-demand]
</term>
<listitem>
<simpara>
        This option is used internally to temporarily provide a
        non-negative default value for the --recurse-submodules
        option.  All other methods of configuring fetch's submodule
        recursion (such as settings in <xref linkend="gitmodules(5)" /> and
        <xref linkend="git-config(1)" />) override this option, as does
        specifying --[no-]recurse-submodules directly.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-u
</term>
<term>
--update-head-ok
</term>
<listitem>
<simpara>
        By default <emphasis>git fetch</emphasis> refuses to update the head which
        corresponds to the current branch.  This flag disables the
        check.  This is purely for the internal use for <emphasis>git pull</emphasis>
        to communicate with <emphasis>git fetch</emphasis>, and unless you are
        implementing your own Porcelain you are not supposed to
        use it.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--upload-pack &lt;upload-pack&gt;
</term>
<listitem>
<simpara>
        When given, and the repository to fetch from is handled
        by <emphasis>git fetch-pack</emphasis>, <emphasis>--exec=&lt;upload-pack&gt;</emphasis> is passed to
        the command to specify non-default path for the command
        run on the other end.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-q
</term>
<term>
--quiet
</term>
<listitem>
<simpara>
        Pass --quiet to git-fetch-pack and silence any other internally
        used git commands. Progress is not reported to the standard error
        stream.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-v
</term>
<term>
--verbose
</term>
<listitem>
<simpara>
        Be verbose.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--progress
</term>
<listitem>
<simpara>
        Progress status is reported on the standard error stream
        by default when it is attached to a terminal, unless -q
        is specified. This flag forces progress status even if the
        standard error stream is not directed to a terminal.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-o &lt;option&gt;
</term>
<term>
--server-option=&lt;option&gt;
</term>
<listitem>
<simpara>
        Transmit the given string to the server when communicating using
        protocol version 2.  The given string must not contain a NUL or LF
        character.  The server's handling of server options, including
        unknown ones, is server-specific.
        When multiple <emphasis>--server-option=&lt;option&gt;</emphasis> are given, they are all
        sent to the other side in the order listed on the command line.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--show-forced-updates
</term>
<listitem>
<simpara>
        By default, git checks if a branch is force-updated during
        fetch. This can be disabled through fetch.showForcedUpdates, but
        the --show-forced-updates option guarantees this check occurs.
        See <xref linkend="git-config(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-show-forced-updates
</term>
<listitem>
<simpara>
        By default, git checks if a branch is force-updated during
        fetch. Pass --no-show-forced-updates or set fetch.showForcedUpdates
        to false to skip this check for performance reasons. If used during
        <emphasis>git-pull</emphasis> the --ff-only option will still check for forced updates
        before attempting a fast-forward update. See <xref linkend="git-config(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-4
</term>
<term>
--ipv4
</term>
<listitem>
<simpara>
        Use IPv4 addresses only, ignoring IPv6 addresses.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-6
</term>
<term>
--ipv6
</term>
<listitem>
<simpara>
        Use IPv6 addresses only, ignoring IPv4 addresses.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;repository&gt;
</term>
<listitem>
<simpara>
        The "remote" repository that is the source of a fetch
        or pull operation.  This parameter can be either a URL
        (see the section <link linkend="git-fetch(1)_URLS">GIT URLS</link> below) or the name
        of a remote (see the section <link linkend="git-fetch(1)_REMOTES">REMOTES</link> below).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;group&gt;
</term>
<listitem>
<simpara>
        A name referring to a list of repositories as the value
        of remotes.&lt;group&gt; in the configuration file.
        (See <xref linkend="git-config(1)" />).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;refspec&gt;
</term>
<listitem>
<simpara>
        Specifies which refs to fetch and which local refs to update.
        When no &lt;refspec&gt;s appear on the command line, the refs to fetch
        are read from <emphasis>remote.&lt;repository&gt;.fetch</emphasis> variables instead
        (see <link linkend="git-fetch(1)_CRTB">CONFIGURED REMOTE-TRACKING BRANCHES</link> below).
</simpara>
<simpara>The format of a &lt;refspec&gt; parameter is an optional plus
<emphasis>+</emphasis>, followed by the source &lt;src&gt;, followed
by a colon <emphasis>:</emphasis>, followed by the destination ref &lt;dst&gt;.
The colon can be omitted when &lt;dst&gt; is empty.  &lt;src&gt; is
typically a ref, but it can also be a fully spelled hex object
name.</simpara>
<simpara>A &lt;refspec&gt; may contain a <emphasis>*</emphasis> in its &lt;src&gt; to indicate a simple pattern
match. Such a refspec functions like a glob that matches any ref with the
same prefix. A pattern &lt;refspec&gt; must have a <emphasis>*</emphasis> in both the &lt;src&gt; and
&lt;dst&gt;. It will map refs to the destination by replacing the <emphasis>*</emphasis> with the
contents matched from the source.</simpara>
<simpara>If a refspec is prefixed by <emphasis>^</emphasis>, it will be interpreted as a negative
refspec. Rather than specifying which refs to fetch or which local refs to
update, such a refspec will instead specify refs to exclude. A ref will be
considered to match if it matches at least one positive refspec, and does
not match any negative refspec. Negative refspecs can be useful to restrict
the scope of a pattern refspec so that it will not include specific refs.
Negative refspecs can themselves be pattern refspecs. However, they may only
contain a &lt;src&gt; and do not specify a &lt;dst&gt;. Fully spelled out hex object
names are also not supported.</simpara>
<simpara><emphasis>tag &lt;tag&gt;</emphasis> means the same as <emphasis>refs/tags/&lt;tag&gt;:refs/tags/&lt;tag&gt;</emphasis>;
it requests fetching everything up to the given tag.</simpara>
<simpara>The remote ref that matches &lt;src&gt;
is fetched, and if &lt;dst&gt; is not an empty string, an attempt
is made to update the local ref that matches it.</simpara>
<simpara>Whether that update is allowed without <emphasis>--force</emphasis> depends on the ref
namespace it's being fetched to, the type of object being fetched, and
whether the update is considered to be a fast-forward. Generally, the
same rules apply for fetching as when pushing, see the <emphasis>&lt;refspec&gt;...</emphasis>
section of <xref linkend="git-push(1)" /> for what those are. Exceptions to those
rules particular to <emphasis>git fetch</emphasis> are noted below.</simpara>
<simpara>Until Git version 2.20, and unlike when pushing with
<xref linkend="git-push(1)" />, any updates to <emphasis>refs/tags/*</emphasis> would be accepted
without <emphasis>+</emphasis> in the refspec (or <emphasis>--force</emphasis>). When fetching, we promiscuously
considered all tag updates from a remote to be forced fetches.  Since
Git version 2.20, fetching to update <emphasis>refs/tags/*</emphasis> works the same way
as when pushing. I.e. any updates will be rejected without <emphasis>+</emphasis> in the
refspec (or <emphasis>--force</emphasis>).</simpara>
<simpara>Unlike when pushing with <xref linkend="git-push(1)" />, any updates outside of
<emphasis>refs/{tags,heads}/*</emphasis> will be accepted without <emphasis>+</emphasis> in the refspec (or
<emphasis>--force</emphasis>), whether that's swapping e.g. a tree object for a blob, or
a commit for another commit that doesn't have the previous commit as
an ancestor etc.</simpara>
<simpara>Unlike when pushing with <xref linkend="git-push(1)" />, there is no
configuration which'll amend these rules, and nothing like a
<emphasis>pre-fetch</emphasis> hook analogous to the <emphasis>pre-receive</emphasis> hook.</simpara>
<simpara>As with pushing with <xref linkend="git-push(1)" />, all of the rules described
above about what's not allowed as an update can be overridden by
adding an optional leading <emphasis>+</emphasis> to a refspec (or using the <emphasis>--force</emphasis>
command line option). The only exception to this is that no amount of
forcing will make the <emphasis>refs/heads/*</emphasis> namespace accept a non-commit
object.</simpara>
<note><simpara>When the remote branch you want to fetch is known to
be rewound and rebased regularly, it is expected that
its new tip will not be a descendant of its previous tip
(as stored in your remote-tracking branch the last time
you fetched).  You would want
to use the <emphasis>+</emphasis> sign to indicate non-fast-forward updates
will be needed for such branches.  There is no way to
determine or declare that a branch will be made available
in a repository with this behavior; the pulling user simply
must know this is the expected usage pattern for a branch.</simpara></note>
</listitem>
</varlistentry>
<varlistentry>
<term>
--stdin
</term>
<listitem>
<simpara>
        Read refspecs, one per line, from stdin in addition to those provided
        as arguments. The "tag &lt;name&gt;" format is not supported.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-fetch(1)__git_urls_anchor_id_git_fetch_1__urls_xreflabel_urls">
<title>GIT URLS<anchor id="git-fetch(1)_URLS" xreflabel="[URLS]"/></title>
<simpara>In general, URLs contain information about the transport protocol, the
address of the remote server, and the path to the repository.
Depending on the transport protocol, some of this information may be
absent.</simpara>
<simpara>Git supports ssh, git, http, and https protocols (in addition, ftp
and ftps can be used for fetching, but this is inefficient and
deprecated; do not use them).</simpara>
<simpara>The native transport (i.e. git:// URL) does no authentication and
should be used with caution on unsecured networks.</simpara>
<simpara>The following syntaxes may be used with them:</simpara>
<itemizedlist>
<listitem>
<simpara>
<literal>ssh://</literal>&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>git://</literal><emphasis>&lt;host&gt;</emphasis>&#91;:<emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>http</literal>&#91;<literal>s</literal>&#93;<literal>://</literal><emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>ftp</literal>&#91;<literal>s</literal>&#93;<literal>://</literal><emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>An alternative scp-like syntax may also be used with the ssh protocol:</simpara>
<itemizedlist>
<listitem>
<simpara>
&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis><literal>:/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>This syntax is only recognized if there are no slashes before the
first colon. This helps differentiate a local path that contains a
colon. For example the local path <emphasis>foo:bar</emphasis> could be specified as an
absolute path or <emphasis>./foo:bar</emphasis> to avoid being misinterpreted as an ssh
url.</simpara>
<simpara>The ssh and git protocols additionally support <literal>~</literal><emphasis>&lt;username&gt;</emphasis> expansion:</simpara>
<itemizedlist>
<listitem>
<simpara>
<literal>ssh://</literal>&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/~</literal><emphasis>&lt;user&gt;</emphasis><literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>git://</literal><emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/~</literal><emphasis>&lt;user&gt;</emphasis><literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis><literal>:~</literal><emphasis>&lt;user&gt;</emphasis><literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>For local repositories, also supported by Git natively, the following
syntaxes may be used:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>/path/to/repo.git/</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>file:///path/to/repo.git/</literal>
</simpara>
</listitem>
</itemizedlist>
<simpara>These two syntaxes are mostly equivalent, except when cloning, when
the former implies <emphasis>--local</emphasis> option. See <xref linkend="git-clone(1)" /> for
details.</simpara>
<simpara><emphasis>git clone</emphasis>, <emphasis>git fetch</emphasis> and <emphasis>git pull</emphasis>, but not <emphasis>git push</emphasis>, will also
accept a suitable bundle file. See <xref linkend="git-bundle(1)" />.</simpara>
<simpara>When Git doesn't know how to handle a certain transport protocol, it
attempts to use the <emphasis>remote-</emphasis><emphasis>&lt;transport&gt;</emphasis> remote helper, if one
exists. To explicitly request a remote helper, the following syntax
may be used:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>&lt;transport&gt;</emphasis>::<emphasis>&lt;address&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>where <emphasis>&lt;address&gt;</emphasis> may be a path, a server and path, or an arbitrary
URL-like string recognized by the specific remote helper being
invoked. See <xref linkend="gitremote-helpers(7)" /> for details.</simpara>
<simpara>If there are a large number of similarly-named remote repositories and
you want to use a different format for them (such that the URLs you
use will be rewritten into URLs that work), you can create a
configuration section of the form:</simpara>
<blockquote>
<literallayout>        [url "<emphasis>&lt;actual-url-base&gt;</emphasis>"]
                insteadOf = <emphasis>&lt;other-url-base&gt;</emphasis></literallayout>
</blockquote>
<simpara>For example, with this:</simpara>
<screen>        [url "git://git.host.xz/"]
                insteadOf = host.xz:/path/to/
                insteadOf = work:</screen>
<simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>
<simpara>If you want to rewrite URLs for push only, you can create a
configuration section of the form:</simpara>
<blockquote>
<literallayout>        [url "<emphasis>&lt;actual-url-base&gt;</emphasis>"]
                pushInsteadOf = <emphasis>&lt;other-url-base&gt;</emphasis></literallayout>
</blockquote>
<simpara>For example, with this:</simpara>
<screen>        [url "ssh://example.org/"]
                pushInsteadOf = git://example.org/</screen>
<simpara>a URL like "git://example.org/path/to/repo.git" will be rewritten to
"ssh://example.org/path/to/repo.git" for pushes, but pulls will still
use the original URL.</simpara>
</simplesect>
<simplesect id="git-fetch(1)__remotes_anchor_id_git_fetch_1__remotes_xreflabel_remotes">
<title>REMOTES<anchor id="git-fetch(1)_REMOTES" xreflabel="[REMOTES]"/></title>
<simpara>The name of one of the following can be used instead
of a URL as <emphasis>&lt;repository&gt;</emphasis> argument:</simpara>
<itemizedlist>
<listitem>
<simpara>
a remote in the Git configuration file: <emphasis>$GIT_DIR/config</emphasis>,
</simpara>
</listitem>
<listitem>
<simpara>
a file in the <emphasis>$GIT_DIR/remotes</emphasis> directory, or
</simpara>
</listitem>
<listitem>
<simpara>
a file in the <emphasis>$GIT_DIR/branches</emphasis> directory.
</simpara>
</listitem>
</itemizedlist>
<simpara>All of these also allow you to omit the refspec from the command line
because they each contain a refspec which git will use by default.</simpara>
<section id="git-fetch(1)__named_remote_in_configuration_file">
<title>Named remote in configuration file</title>
<simpara>You can choose to provide the name of a remote which you had previously
configured using <xref linkend="git-remote(1)" />, <xref linkend="git-config(1)" />
or even by a manual edit to the <emphasis>$GIT_DIR/config</emphasis> file.  The URL of
this remote will be used to access the repository.  The refspec
of this remote will be used by default when you do
not provide a refspec on the command line.  The entry in the
config file would appear like this:</simpara>
<screen>        [remote "&lt;name&gt;"]
                url = &lt;URL&gt;
                pushurl = &lt;pushurl&gt;
                push = &lt;refspec&gt;
                fetch = &lt;refspec&gt;</screen>
<simpara>The <emphasis>&lt;pushurl&gt;</emphasis> is used for pushes only. It is optional and defaults
to <emphasis>&lt;URL&gt;</emphasis>. Pushing to a remote affects all defined pushurls or all
defined urls if no pushurls are defined. Fetch, however, will only
fetch from the first defined url if multiple urls are defined.</simpara>
</section>
<section id="git-fetch(1)__named_file_in_emphasis_git_dir_remotes_emphasis">
<title>Named file in <emphasis>$GIT_DIR/remotes</emphasis></title>
<simpara>You can choose to provide the name of a
file in <emphasis>$GIT_DIR/remotes</emphasis>.  The URL
in this file will be used to access the repository.  The refspec
in this file will be used as default when you do not
provide a refspec on the command line.  This file should have the
following format:</simpara>
<screen>        URL: one of the above URL formats
        Push: &lt;refspec&gt;
        Pull: &lt;refspec&gt;</screen>
<simpara><emphasis>Push:</emphasis> lines are used by <emphasis>git push</emphasis> and
<emphasis>Pull:</emphasis> lines are used by <emphasis>git pull</emphasis> and <emphasis>git fetch</emphasis>.
Multiple <emphasis>Push:</emphasis> and <emphasis>Pull:</emphasis> lines may
be specified for additional branch mappings.</simpara>
</section>
<section id="git-fetch(1)__named_file_in_emphasis_git_dir_branches_emphasis">
<title>Named file in <emphasis>$GIT_DIR/branches</emphasis></title>
<simpara>You can choose to provide the name of a
file in <emphasis>$GIT_DIR/branches</emphasis>.
The URL in this file will be used to access the repository.
This file should have the following format:</simpara>
<screen>        &lt;URL&gt;#&lt;head&gt;</screen>
<simpara><emphasis>&lt;URL&gt;</emphasis> is required; <emphasis>#&lt;head&gt;</emphasis> is optional.</simpara>
<simpara>Depending on the operation, git will use one of the following
refspecs, if you don't provide one on the command line.
<emphasis>&lt;branch&gt;</emphasis> is the name of this file in <emphasis>$GIT_DIR/branches</emphasis> and
<emphasis>&lt;head&gt;</emphasis> defaults to <emphasis>master</emphasis>.</simpara>
<simpara>git fetch uses:</simpara>
<screen>        refs/heads/&lt;head&gt;:refs/heads/&lt;branch&gt;</screen>
<simpara>git push uses:</simpara>
<screen>        HEAD:refs/heads/&lt;head&gt;</screen>
</section>
</simplesect>
<simplesect id="git-fetch(1)__configured_remote_tracking_branches_anchor_id_git_fetch_1__crtb_xreflabel_crtb">
<title>CONFIGURED REMOTE-TRACKING BRANCHES<anchor id="git-fetch(1)_CRTB" xreflabel="[CRTB]"/></title>
<simpara>You often interact with the same remote repository by
regularly and repeatedly fetching from it.  In order to keep track
of the progress of such a remote repository, <emphasis>git fetch</emphasis> allows you
to configure <emphasis>remote.&lt;repository&gt;.fetch</emphasis> configuration variables.</simpara>
<simpara>Typically such a variable may look like this:</simpara>
<screen>[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*</screen>
<simpara>This configuration is used in two ways:</simpara>
<itemizedlist>
<listitem>
<simpara>
When <emphasis>git fetch</emphasis> is run without specifying what branches
  and/or tags to fetch on the command line, e.g. <emphasis>git fetch origin</emphasis>
  or <emphasis>git fetch</emphasis>, <emphasis>remote.&lt;repository&gt;.fetch</emphasis> values are used as
  the refspecs--they specify which refs to fetch and which local refs
  to update.  The example above will fetch
  all branches that exist in the <emphasis>origin</emphasis> (i.e. any ref that matches
  the left-hand side of the value, <emphasis>refs/heads/*</emphasis>) and update the
  corresponding remote-tracking branches in the <emphasis>refs/remotes/origin/*</emphasis>
  hierarchy.
</simpara>
</listitem>
<listitem>
<simpara>
When <emphasis>git fetch</emphasis> is run with explicit branches and/or tags
  to fetch on the command line, e.g. <emphasis>git fetch origin master</emphasis>, the
  &lt;refspec&gt;s given on the command line determine what are to be
  fetched (e.g. <emphasis>master</emphasis> in the example,
  which is a short-hand for <emphasis>master:</emphasis>, which in turn means
  "fetch the <emphasis>master</emphasis> branch but I do not explicitly say what
  remote-tracking branch to update with it from the command line"),
  and the example command will
  fetch <emphasis>only</emphasis> the <emphasis>master</emphasis> branch.  The <emphasis>remote.&lt;repository&gt;.fetch</emphasis>
  values determine which
  remote-tracking branch, if any, is updated.  When used in this
  way, the <emphasis>remote.&lt;repository&gt;.fetch</emphasis> values do not have any
  effect in deciding <emphasis>what</emphasis> gets fetched (i.e. the values are not
  used as refspecs when the command-line lists refspecs); they are
  only used to decide <emphasis>where</emphasis> the refs that are fetched are stored
  by acting as a mapping.
</simpara>
</listitem>
</itemizedlist>
<simpara>The latter use of the <emphasis>remote.&lt;repository&gt;.fetch</emphasis> values can be
overridden by giving the <emphasis>--refmap=&lt;refspec&gt;</emphasis> parameter(s) on the
command line.</simpara>
</simplesect>
<simplesect id="git-fetch(1)__pruning">
<title>PRUNING</title>
<simpara>Git has a default disposition of keeping data unless it's explicitly
thrown away; this extends to holding onto local references to branches
on remotes that have themselves deleted those branches.</simpara>
<simpara>If left to accumulate, these stale references might make performance
worse on big and busy repos that have a lot of branch churn, and
e.g. make the output of commands like <emphasis>git branch -a --contains
&lt;commit&gt;</emphasis> needlessly verbose, as well as impacting anything else
that'll work with the complete set of known references.</simpara>
<simpara>These remote-tracking references can be deleted as a one-off with
either of:</simpara>
<screen># While fetching
$ git fetch --prune &lt;name&gt;

# Only prune, don't fetch
$ git remote prune &lt;name&gt;</screen>
<simpara>To prune references as part of your normal workflow without needing to
remember to run that, set <emphasis>fetch.prune</emphasis> globally, or
<emphasis>remote.&lt;name&gt;.prune</emphasis> per-remote in the config. See
<xref linkend="git-config(1)" />.</simpara>
<simpara>Here's where things get tricky and more specific. The pruning feature
doesn't actually care about branches, instead it'll prune local &#8592;&#8594;
remote-references as a function of the refspec of the remote (see
<emphasis>&lt;refspec&gt;</emphasis> and <link linkend="git-fetch(1)_CRTB">CONFIGURED REMOTE-TRACKING BRANCHES</link> above).</simpara>
<simpara>Therefore if the refspec for the remote includes
e.g. <emphasis>refs/tags/*:refs/tags/*</emphasis>, or you manually run e.g. <emphasis>git fetch
--prune &lt;name&gt; "refs/tags/*:refs/tags/*"</emphasis> it won't be stale remote
tracking branches that are deleted, but any local tag that doesn't
exist on the remote.</simpara>
<simpara>This might not be what you expect, i.e. you want to prune remote
<emphasis>&lt;name&gt;</emphasis>, but also explicitly fetch tags from it, so when you fetch
from it you delete all your local tags, most of which may not have
come from the <emphasis>&lt;name&gt;</emphasis> remote in the first place.</simpara>
<simpara>So be careful when using this with a refspec like
<emphasis>refs/tags/*:refs/tags/*</emphasis>, or any other refspec which might map
references from multiple remotes to the same local namespace.</simpara>
<simpara>Since keeping up-to-date with both branches and tags on the remote is
a common use-case the <emphasis>--prune-tags</emphasis> option can be supplied along with
<emphasis>--prune</emphasis> to prune local tags that don't exist on the remote, and
force-update those tags that differ. Tag pruning can also be enabled
with <emphasis>fetch.pruneTags</emphasis> or <emphasis>remote.&lt;name&gt;.pruneTags</emphasis> in the config. See
<xref linkend="git-config(1)" />.</simpara>
<simpara>The <emphasis>--prune-tags</emphasis> option is equivalent to having
<emphasis>refs/tags/*:refs/tags/*</emphasis> declared in the refspecs of the remote. This
can lead to some seemingly strange interactions:</simpara>
<screen># These both fetch tags
$ git fetch --no-tags origin 'refs/tags/*:refs/tags/*'
$ git fetch --no-tags --prune-tags origin</screen>
<simpara>The reason it doesn't error out when provided without <emphasis>--prune</emphasis> or its
config versions is for flexibility of the configured versions, and to
maintain a 1=1 mapping between what the command line flags do, and
what the configuration versions do.</simpara>
<simpara>It's reasonable to e.g. configure <emphasis>fetch.pruneTags=true</emphasis> in
<emphasis>~/.gitconfig</emphasis> to have tags pruned whenever <emphasis>git fetch --prune</emphasis> is
run, without making every invocation of <emphasis>git fetch</emphasis> without <emphasis>--prune</emphasis>
an error.</simpara>
<simpara>Pruning tags with <emphasis>--prune-tags</emphasis> also works when fetching a URL
instead of a named remote. These will all prune tags not found on
origin:</simpara>
<screen>$ git fetch origin --prune --prune-tags
$ git fetch origin --prune 'refs/tags/*:refs/tags/*'
$ git fetch &lt;url-of-origin&gt; --prune --prune-tags
$ git fetch &lt;url-of-origin&gt; --prune 'refs/tags/*:refs/tags/*'</screen>
</simplesect>
<simplesect id="git-fetch(1)__output">
<title>OUTPUT</title>
<simpara>The output of "git fetch" depends on the transport method used; this
section describes the output when fetching over the Git protocol
(either locally or via ssh) and Smart HTTP protocol.</simpara>
<simpara>The status of the fetch is output in tabular form, with each line
representing the status of a single ref. Each line is of the form:</simpara>
<screen> &lt;flag&gt; &lt;summary&gt; &lt;from&gt; -&gt; &lt;to&gt; [&lt;reason&gt;]</screen>
<simpara>When using <emphasis>--porcelain</emphasis>, the output format is intended to be
machine-parseable. In contrast to the human-readable output formats it
thus prints to standard output instead of standard error. Each line is
of the form:</simpara>
<screen>&lt;flag&gt; &lt;old-object-id&gt; &lt;new-object-id&gt; &lt;local-reference&gt;</screen>
<simpara>The status of up-to-date refs is shown only if the --verbose option is
used.</simpara>
<simpara>In compact output mode, specified with configuration variable
fetch.output, if either entire <emphasis>&lt;from&gt;</emphasis> or <emphasis>&lt;to&gt;</emphasis> is found in the
other string, it will be substituted with <emphasis>*</emphasis> in the other string. For
example, <emphasis>master -&gt; origin/master</emphasis> becomes <emphasis>master -&gt; origin/*</emphasis>.</simpara>
<variablelist>
<varlistentry>
<term>
flag
</term>
<listitem>
<simpara>
        A single character indicating the status of the ref:
</simpara>
<variablelist>
<varlistentry>
<term>
(space)
</term>
<listitem>
<simpara>
for a successfully fetched fast-forward;
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>+</emphasis>
</term>
<listitem>
<simpara>
for a successful forced update;
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-</emphasis>
</term>
<listitem>
<simpara>
for a successfully pruned ref;
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>t</emphasis>
</term>
<listitem>
<simpara>
for a successful tag update;
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>*</emphasis>
</term>
<listitem>
<simpara>
for a successfully fetched new ref;
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>!</emphasis>
</term>
<listitem>
<simpara>
for a ref that was rejected or failed to update; and
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>=</emphasis>
</term>
<listitem>
<simpara>
for a ref that was up to date and did not need fetching.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term>
summary
</term>
<listitem>
<simpara>
        For a successfully fetched ref, the summary shows the old and new
        values of the ref in a form suitable for using as an argument to
        <emphasis>git log</emphasis> (this is <emphasis>&lt;old&gt;..&lt;new&gt;</emphasis> in most cases, and
        <emphasis>&lt;old&gt;...&lt;new&gt;</emphasis> for forced non-fast-forward updates).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
from
</term>
<listitem>
<simpara>
        The name of the remote ref being fetched from, minus its
        <emphasis>refs/&lt;type&gt;/</emphasis> prefix. In the case of deletion, the name of
        the remote ref is "(none)".
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
to
</term>
<listitem>
<simpara>
        The name of the local ref being updated, minus its
        <emphasis>refs/&lt;type&gt;/</emphasis> prefix.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
reason
</term>
<listitem>
<simpara>
        A human-readable explanation. In the case of successfully fetched
        refs, no explanation is needed. For a failed ref, the reason for
        failure is described.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-fetch(1)__examples">
<title>EXAMPLES</title>
<itemizedlist>
<listitem>
<simpara>
Update the remote-tracking branches:
</simpara>
<screen>$ git fetch origin</screen>
<simpara>The above command copies all branches from the remote <emphasis>refs/heads/</emphasis>
namespace and stores them to the local <emphasis>refs/remotes/origin/</emphasis> namespace,
unless the <emphasis>remote.&lt;repository&gt;.fetch</emphasis> option is used to specify a
non-default refspec.</simpara>
</listitem>
<listitem>
<simpara>
Using refspecs explicitly:
</simpara>
<screen>$ git fetch origin +seen:seen maint:tmp</screen>
<simpara>This updates (or creates, as necessary) branches <emphasis>seen</emphasis> and <emphasis>tmp</emphasis> in
the local repository by fetching from the branches (respectively)
<emphasis>seen</emphasis> and <emphasis>maint</emphasis> from the remote repository.</simpara>
<simpara>The <emphasis>seen</emphasis> branch will be updated even if it does not fast-forward,
because it is prefixed with a plus sign; <emphasis>tmp</emphasis> will not be.</simpara>
</listitem>
<listitem>
<simpara>
Peek at a remote's branch, without configuring the remote in your local
  repository:
</simpara>
<screen>$ git fetch git://git.kernel.org/pub/scm/git/git.git maint
$ git log FETCH_HEAD</screen>
<simpara>The first command fetches the <emphasis>maint</emphasis> branch from the repository at
<emphasis>git://git.kernel.org/pub/scm/git/git.git</emphasis> and the second command uses
<emphasis>FETCH_HEAD</emphasis> to examine the branch with <xref linkend="git-log(1)" />.  The fetched
objects will eventually be removed by git's built-in housekeeping (see
<xref linkend="git-gc(1)" />).</simpara>
</listitem>
</itemizedlist>
</simplesect>
<simplesect id="git-fetch(1)__security">
<title>SECURITY</title>
<simpara>The fetch and push protocols are not designed to prevent one side from
stealing data from the other repository that was not intended to be
shared. If you have private data that you need to protect from a malicious
peer, your best option is to store it in another repository. This applies
to both clients and servers. In particular, namespaces on a server are not
effective for read access control; you should only grant read access to a
namespace to clients that you would trust with read access to the entire
repository.</simpara>
<simpara>The known attack vectors are as follows:</simpara>
<orderedlist numeration="arabic">
<listitem>
<simpara>
The victim sends "have" lines advertising the IDs of objects it has that
  are not explicitly intended to be shared but can be used to optimize the
  transfer if the peer also has them. The attacker chooses an object ID X
  to steal and sends a ref to X, but isn't required to send the content of
  X because the victim already has it. Now the victim believes that the
  attacker has X, and it sends the content of X back to the attacker
  later. (This attack is most straightforward for a client to perform on a
  server, by creating a ref to X in the namespace the client has access
  to and then fetching it. The most likely way for a server to perform it
  on a client is to "merge" X into a public branch and hope that the user
  does additional work on this branch and pushes it back to the server
  without noticing the merge.)
</simpara>
</listitem>
<listitem>
<simpara>
As in #1, the attacker chooses an object ID X to steal. The victim sends
  an object Y that the attacker already has, and the attacker falsely
  claims to have X and not Y, so the victim sends Y as a delta against X.
  The delta reveals regions of X that are similar to Y to the attacker.
</simpara>
</listitem>
</orderedlist>
</simplesect>
<simplesect id="git-fetch(1)__configuration">
<title>CONFIGURATION</title>
<simpara>Everything below this line in this section is selectively included
from the <xref linkend="git-config(1)" /> documentation. The content is the same
as what's found there:</simpara>
<variablelist>
<varlistentry>
<term>
fetch.recurseSubmodules
</term>
<listitem>
<simpara>
        This option controls whether <emphasis>git fetch</emphasis> (and the underlying fetch
        in <emphasis>git pull</emphasis>) will recursively fetch into populated submodules.
        This option can be set either to a boolean value or to <emphasis>on-demand</emphasis>.
        Setting it to a boolean changes the behavior of fetch and pull to
        recurse unconditionally into submodules when set to true or to not
        recurse at all when set to false. When set to <emphasis>on-demand</emphasis>, fetch and
        pull will only recurse into a populated submodule when its
        superproject retrieves a commit that updates the submodule's
        reference.
        Defaults to <emphasis>on-demand</emphasis>, or to the value of <emphasis>submodule.recurse</emphasis> if set.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.fsckObjects
</term>
<listitem>
<simpara>
        If it is set to true, git-fetch-pack will check all fetched
        objects. See <emphasis>transfer.fsckObjects</emphasis> for what's
        checked. Defaults to false. If not set, the value of
        <emphasis>transfer.fsckObjects</emphasis> is used instead.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.fsck.&lt;msg-id&gt;
</term>
<listitem>
<simpara>
        Acts like <emphasis>fsck.&lt;msg-id&gt;</emphasis>, but is used by
        <xref linkend="git-fetch-pack(1)" /> instead of <xref linkend="git-fsck(1)" />. See
        the <emphasis>fsck.&lt;msg-id&gt;</emphasis> documentation for details.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.fsck.skipList
</term>
<listitem>
<simpara>
        Acts like <emphasis>fsck.skipList</emphasis>, but is used by
        <xref linkend="git-fetch-pack(1)" /> instead of <xref linkend="git-fsck(1)" />. See
        the <emphasis>fsck.skipList</emphasis> documentation for details.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.unpackLimit
</term>
<listitem>
<simpara>
        If the number of objects fetched over the Git native
        transfer is below this
        limit, then the objects will be unpacked into loose object
        files. However if the number of received objects equals or
        exceeds this limit then the received pack will be stored as
        a pack, after adding any missing delta bases.  Storing the
        pack from a push can make the push operation complete faster,
        especially on slow filesystems.  If not set, the value of
        <emphasis>transfer.unpackLimit</emphasis> is used instead.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.prune
</term>
<listitem>
<simpara>
        If true, fetch will automatically behave as if the <emphasis>--prune</emphasis>
        option was given on the command line.  See also <emphasis>remote.&lt;name&gt;.prune</emphasis>
        and the PRUNING section of <xref linkend="git-fetch(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.pruneTags
</term>
<listitem>
<simpara>
        If true, fetch will automatically behave as if the
        <emphasis>refs/tags/*:refs/tags/*</emphasis> refspec was provided when pruning,
        if not set already. This allows for setting both this option
        and <emphasis>fetch.prune</emphasis> to maintain a 1=1 mapping to upstream
        refs. See also <emphasis>remote.&lt;name&gt;.pruneTags</emphasis> and the PRUNING
        section of <xref linkend="git-fetch(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.all
</term>
<listitem>
<simpara>
        If true, fetch will attempt to update all available remotes.
        This behavior can be overridden by passing <emphasis>--no-all</emphasis> or by
        explicitly specifying one or more remote(s) to fetch from.
        Defaults to false.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.output
</term>
<listitem>
<simpara>
        Control how ref update status is printed. Valid values are
        <emphasis>full</emphasis> and <emphasis>compact</emphasis>. Default value is <emphasis>full</emphasis>. See the
        OUTPUT section in <xref linkend="git-fetch(1)" /> for details.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.negotiationAlgorithm
</term>
<listitem>
<simpara>
        Control how information about the commits in the local repository
        is sent when negotiating the contents of the packfile to be sent by
        the server.  Set to "consecutive" to use an algorithm that walks
        over consecutive commits checking each one.  Set to "skipping" to
        use an algorithm that skips commits in an effort to converge
        faster, but may result in a larger-than-necessary packfile; or set
        to "noop" to not send any information at all, which will almost
        certainly result in a larger-than-necessary packfile, but will skip
        the negotiation step.  Set to "default" to override settings made
        previously and use the default behaviour.  The default is normally
        "consecutive", but if <emphasis>feature.experimental</emphasis> is true, then the
        default is "skipping".  Unknown values will cause <emphasis>git fetch</emphasis> to
        error out.
</simpara>
<simpara>See also the <emphasis>--negotiate-only</emphasis> and <emphasis>--negotiation-tip</emphasis> options to
<xref linkend="git-fetch(1)" />.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.showForcedUpdates
</term>
<listitem>
<simpara>
        Set to false to enable <emphasis>--no-show-forced-updates</emphasis> in
        <xref linkend="git-fetch(1)" /> and <xref linkend="git-pull(1)" /> commands.
        Defaults to true.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.parallel
</term>
<listitem>
<simpara>
        Specifies the maximal number of fetch operations to be run in parallel
        at a time (submodules, or remotes when the <emphasis>--multiple</emphasis> option of
        <xref linkend="git-fetch(1)" /> is in effect).
</simpara>
<simpara>A value of 0 will give some reasonable default. If unset, it defaults to 1.</simpara>
<simpara>For submodules, this setting can be overridden using the <emphasis>submodule.fetchJobs</emphasis>
config setting.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.writeCommitGraph
</term>
<listitem>
<simpara>
        Set to true to write a commit-graph after every <emphasis>git fetch</emphasis> command
        that downloads a pack-file from a remote. Using the <emphasis>--split</emphasis> option,
        most executions will create a very small commit-graph file on top of
        the existing commit-graph file(s). Occasionally, these files will
        merge and the write may take longer. Having an updated commit-graph
        file helps performance of many Git commands, including <emphasis>git merge-base</emphasis>,
        <emphasis>git push -f</emphasis>, and <emphasis>git log --graph</emphasis>. Defaults to false.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.bundleURI
</term>
<listitem>
<simpara>
        This value stores a URI for downloading Git object data from a bundle
        URI before performing an incremental fetch from the origin Git server.
        This is similar to how the <emphasis>--bundle-uri</emphasis> option behaves in
        <xref linkend="git-clone(1)" />. <emphasis>git clone --bundle-uri</emphasis> will set the
        <emphasis>fetch.bundleURI</emphasis> value if the supplied bundle URI contains a bundle
        list that is organized for incremental fetches.
</simpara>
<simpara>If you modify this value and your repository has a <emphasis>fetch.bundleCreationToken</emphasis>
value, then remove that <emphasis>fetch.bundleCreationToken</emphasis> value before fetching from
the new bundle URI.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
fetch.bundleCreationToken
</term>
<listitem>
<simpara>
        When using <emphasis>fetch.bundleURI</emphasis> to fetch incrementally from a bundle
        list that uses the "creationToken" heuristic, this config value
        stores the maximum <emphasis>creationToken</emphasis> value of the downloaded bundles.
        This value is used to prevent downloading bundles in the future
        if the advertised <emphasis>creationToken</emphasis> is not strictly larger than this
        value.
</simpara>
<simpara>The creation token values are chosen by the provider serving the specific
bundle URI. If you modify the URI at <emphasis>fetch.bundleURI</emphasis>, then be sure to
remove the value for the <emphasis>fetch.bundleCreationToken</emphasis> value before fetching.</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-fetch(1)__bugs">
<title>BUGS</title>
<simpara>Using --recurse-submodules can only fetch new commits in submodules that are
present locally e.g. in <emphasis>$GIT_DIR/modules/</emphasis>. If the upstream adds a new
submodule, that submodule cannot be fetched until it is cloned e.g. by <emphasis>git
submodule update</emphasis>. This is expected to be fixed in a future Git version.</simpara>
</simplesect>
<simplesect id="git-fetch(1)__see_also">
<title>SEE ALSO</title>
<simpara><xref linkend="git-pull(1)" /></simpara>
</simplesect>
<simplesect id="git-fetch(1)__git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
</simplesect>
</sect2>
