'\" t
.\" Title: git-fetch
.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot
.\" Date: 2026-02-01
.\" Manual: Git Manual
.\" Source: Git 2.53.0
.\" Language: English
.\"
.TH "GIT\-FETCH" "1" "2026\-02\-01" "Git 2\&.53\&.0" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-fetch \- Download objects and refs from another repository
.SH "SYNOPSIS"
.sp
.nf
\fBgit\fR \fBfetch\fR [\fI\fR] [\fI\fR [\fI\fR\&...]]
\fBgit\fR \fBfetch\fR [\fI\fR] \fI\fR
\fBgit\fR \fBfetch\fR \fB\-\-multiple\fR [\fI\fR] [(\fI\fR|\fI\fR)\&...]
\fBgit\fR \fBfetch\fR \fB\-\-all\fR [\fI\fR]
.fi
.sp
.SH "DESCRIPTION"
.sp
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 \fI\fR below for ways to control this behavior)\&.
.sp
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 \fB\-\-tags\fR or \fB\-\-no\-tags\fR options or by configuring \fBremote\&.\fR\fI\fR\fB\&.tagOpt\fR\&. By using a refspec that fetches tags explicitly, you can fetch tags that do not point into branches you are interested in as well\&.
.sp
\fBgit\fR \fBfetch\fR can fetch from either a single named repository or URL, or from several repositories at once if \fI\fR is given and there is a \fBremotes\&.\fR\fI\fR entry in the configuration file\&. (See \fBgit-config\fR(1))\&.
.sp
When no remote is specified, by default the \fBorigin\fR remote will be used, unless there\(cqs an upstream branch configured for the current branch\&.
.sp
The names of refs that are fetched, together with the object names they point at, are written to \fB\&.git/FETCH_HEAD\fR\&. This information may be used by scripts or other git commands, such as \fBgit-pull\fR(1)\&.
.SH "OPTIONS"
.PP
\fB\-\-all\fR, \fB\-\-no\-all\fR
.RS 4
Fetch all remotes, except for the ones that has the
\fBremote\&.\fR\fI\fR\fB\&.skipFetchAll\fR
configuration variable set\&. This overrides the configuration variable
\fBfetch\&.all\fR\&.
.RE
.PP
\fB\-a\fR, \fB\-\-append\fR
.RS 4
Append ref names and object names of fetched refs to the existing contents of
\fB\&.git/FETCH_HEAD\fR\&. Without this option old data in
\fB\&.git/FETCH_HEAD\fR
will be overwritten\&.
.RE
.PP
\fB\-\-atomic\fR
.RS 4
Use an atomic transaction to update local refs\&. Either all refs are updated, or on error, no refs are updated\&.
.RE
.PP
\fB\-\-depth=\fR\fI\fR
.RS 4
Limit fetching to the specified number of commits from the tip of each remote branch history\&. If fetching to a
\fIshallow\fR
repository created by
\fBgit\fR
\fBclone\fR
with
\fB\-\-depth=\fR\fI\fR
option (see
\fBgit-clone\fR(1)), deepen or shorten the history to the specified number of commits\&. Tags for the deepened commits are not fetched\&.
.RE
.PP
\fB\-\-deepen=\fR\fI\fR
.RS 4
Similar to
\fB\-\-depth\fR, except it specifies the number of commits from the current shallow boundary instead of from the tip of each remote branch history\&.
.RE
.PP
\fB\-\-shallow\-since=\fR\fI\fR
.RS 4
Deepen or shorten the history of a shallow repository to include all reachable commits after
\fI\fR\&.
.RE
.PP
\fB\-\-shallow\-exclude=\fR\fI\fR
.RS 4
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\&.
.RE
.PP
\fB\-\-unshallow\fR
.RS 4
If the source repository is complete, convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories\&.
.sp
If the source repository is shallow, fetch as much as possible so that the current repository has the same history as the source repository\&.
.RE
.PP
\fB\-\-update\-shallow\fR
.RS 4
By default when fetching from a shallow repository,
\fBgit\fR
\fBfetch\fR
refuses refs that require updating
\fB\&.git/shallow\fR\&. This option updates
\fB\&.git/shallow\fR
and accepts such refs\&.
.RE
.PP
\fB\-\-negotiation\-tip=\fR(\fI\fR|\fI\fR)
.RS 4
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\&.
.sp
This option may be specified more than once; if so, Git will report commits reachable from any of the given commits\&.
.sp
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\&.
.sp
See also the
\fBfetch\&.negotiationAlgorithm\fR
and
\fBpush\&.negotiate\fR
configuration variables documented in
\fBgit-config\fR(1), and the
\fB\-\-negotiate\-only\fR
option below\&.
.RE
.PP
\fB\-\-negotiate\-only\fR
.RS 4
Do not fetch anything from the server, and instead print the ancestors of the provided
\fB\-\-negotiation\-tip=\fR
arguments, which we have in common with the server\&.
.sp
This is incompatible with
\fB\-\-recurse\-submodules=\fR(\fByes\fR|\fBon\-demand\fR)\&. Internally this is used to implement the
\fBpush\&.negotiate\fR
option, see
\fBgit-config\fR(1)\&.
.RE
.PP
\fB\-\-dry\-run\fR
.RS 4
Show what would be done, without making any changes\&.
.RE
.PP
\fB\-\-porcelain\fR
.RS 4
Print the output to standard output in an easy\-to\-parse format for scripts\&. See section OUTPUT in
\fBgit-fetch\fR(1)
for details\&.
.sp
This is incompatible with
\fB\-\-recurse\-submodules=\fR(\fByes\fR|\fBon\-demand\fR) and takes precedence over the
\fBfetch\&.output\fR
config option\&.
.RE
.PP
\fB\-\-write\-fetch\-head\fR, \fB\-\-no\-write\-fetch\-head\fR
.RS 4
Write the list of remote refs fetched in the
\fBFETCH_HEAD\fR
file directly under
\fB$GIT_DIR\fR\&. This is the default\&. Passing
\fB\-\-no\-write\-fetch\-head\fR
from the command line tells Git not to write the file\&. Under
\fB\-\-dry\-run\fR
option, the file is never written\&.
.RE
.PP
\fB\-f\fR, \fB\-\-force\fR
.RS 4
When
\fBgit\fR
\fBfetch\fR
is used with
\fI\fR\fB:\fR\fI\fR
refspec, it may refuse to update the local branch as discussed in the
\fI\fR
part below\&. This option overrides that check\&.
.RE
.PP
\fB\-k\fR, \fB\-\-keep\fR
.RS 4
Keep downloaded pack\&.
.RE
.PP
\fB\-\-multiple\fR
.RS 4
Allow several
\fI\fR
and
\fI\fR
arguments to be specified\&. No
\fI\fRs may be specified\&.
.RE
.PP
\fB\-\-auto\-maintenance\fR, \fB\-\-no\-auto\-maintenance\fR, \fB\-\-auto\-gc\fR, \fB\-\-no\-auto\-gc\fR
.RS 4
Run
\fBgit\fR
\fBmaintenance\fR
\fBrun\fR
\fB\-\-auto\fR
at the end to perform automatic repository maintenance if needed\&. This is enabled by default\&.
.RE
.PP
\fB\-\-write\-commit\-graph\fR, \fB\-\-no\-write\-commit\-graph\fR
.RS 4
Write a commit\-graph after fetching\&. This overrides the config setting
\fBfetch\&.writeCommitGraph\fR\&.
.RE
.PP
\fB\-\-prefetch\fR
.RS 4
Modify the configured refspec to place all refs into the
\fBrefs/prefetch/\fR
namespace\&. See the
\fBprefetch\fR
task in
\fBgit-maintenance\fR(1)\&.
.RE
.PP
\fB\-p\fR, \fB\-\-prune\fR
.RS 4
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
\fB\-\-tags\fR
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
\fB\-\-mirror\fR
option), then they are also subject to pruning\&. Supplying
\fB\-\-prune\-tags\fR
is a shorthand for providing the tag refspec\&.
.sp
See the PRUNING section below for more details\&.
.RE
.PP
\fB\-P\fR, \fB\-\-prune\-tags\fR
.RS 4
Before fetching, remove any local tags that no longer exist on the remote if
\fB\-\-prune\fR
is enabled\&. This option should be used more carefully, unlike
\fB\-\-prune\fR
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
\fB\-\-prune\fR, see the discussion about that in its documentation\&.
.sp
See the PRUNING section below for more details\&.
.RE
.PP
\fB\-n\fR, \fB\-\-no\-tags\fR
.RS 4
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
\fBremote\&.\fR\fI\fR\fB\&.tagOpt\fR
setting\&. See
\fBgit-config\fR(1)\&.
.RE
.PP
\fB\-\-refetch\fR
.RS 4
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
\fB\-\-filter=\fR
when the filter definition has changed\&. Automatic post\-fetch maintenance will perform object database pack consolidation to remove any duplicate objects\&.
.RE
.PP
\fB\-\-refmap=\fR\fI\fR
.RS 4
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
\fBremote\&.\fR\fI\fR\fB\&.fetch\fR
configuration variables for the remote repository\&. Providing an empty
\fI\fR
to the
\fB\-\-refmap\fR
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\&.
.RE
.PP
\fB\-t\fR, \fB\-\-tags\fR
.RS 4
Fetch all tags from the remote (i\&.e\&., fetch remote tags
\fBrefs/tags/*\fR
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
\fB\-\-prune\fR
is used (though tags may be pruned anyway if they are also the destination of an explicit refspec; see
\fB\-\-prune\fR)\&.
.RE
.PP
\fB\-\-recurse\-submodules\fR[\fB=\fR(\fByes\fR|\fBon\-demand\fR|\fBno\fR)]
.RS 4
Control if and under what conditions new commits of submodules should be fetched too\&. When recursing through submodules,
\fBgit\fR
\fBfetch\fR
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
\fB$GIT_DIR/modules/\fR
(see
\fBgitsubmodules\fR(7)); if the upstream adds a new submodule, that submodule cannot be fetched until it is cloned e\&.g\&. by
\fBgit\fR
\fBsubmodule\fR
\fBupdate\fR\&.
.sp
When set to
\fBon\-demand\fR, only changed submodules are fetched\&. When set to
\fByes\fR, all populated submodules are fetched and submodules that are both unpopulated and changed are fetched\&. When set to
\fBno\fR, submodules are never fetched\&.
.sp
When unspecified, this uses the value of
\fBfetch\&.recurseSubmodules\fR
if it is set (see
\fBgit-config\fR(1)), defaulting to
\fBon\-demand\fR
if unset\&. When this option is used without any value, it defaults to
\fByes\fR\&.
.RE
.PP
\fB\-j\fR \fI\fR, \fB\-\-jobs=\fR\fI\fR
.RS 4
Parallelize all forms of fetching up to
\fI\fR
jobs at a time\&.
.sp
If the
\fB\-\-multiple\fR
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
\fBfetch\&.parallel\fR
and
\fBsubmodule\&.fetchJobs\fR
(see
\fBgit-config\fR(1))\&.
.sp
Typically, parallel recursive and multi\-remote fetches will be faster\&. By default fetches are performed sequentially, not in parallel\&.
.RE
.PP
\fB\-\-no\-recurse\-submodules\fR
.RS 4
Disable recursive fetching of submodules (this has the same effect as using the
\fB\-\-recurse\-submodules=no\fR
option)\&.
.RE
.PP
\fB\-\-set\-upstream\fR
.RS 4
If the remote is fetched successfully, add upstream (tracking) reference, used by argument\-less
\fBgit-pull\fR(1)
and other commands\&. For more information, see
\fBbranch\&.\fR\fI\fR\fB\&.merge\fR
and
\fBbranch\&.\fR\fI\fR\fB\&.remote\fR
in
\fBgit-config\fR(1)\&.
.RE
.PP
\fB\-\-submodule\-prefix=\fR\fI\fR
.RS 4
Prepend
\fI\fR
to paths printed in informative messages such as "Fetching submodule foo"\&. This option is used internally when recursing over submodules\&.
.RE
.PP
\fB\-\-recurse\-submodules\-default=\fR(\fByes\fR|\fBon\-demand\fR)
.RS 4
This option is used internally to temporarily provide a non\-negative default value for the
\fB\-\-recurse\-submodules\fR
option\&. All other methods of configuring fetch\(cqs submodule recursion (such as settings in
\fBgitmodules\fR(5)
and
\fBgit-config\fR(1)) override this option, as does specifying
\fB\-\-\fR[\fBno\-\fR]\fBrecurse\-submodules\fR
directly\&.
.RE
.PP
\fB\-u\fR, \fB\-\-update\-head\-ok\fR
.RS 4
By default
\fBgit\fR
\fBfetch\fR
refuses to update the head which corresponds to the current branch\&. This flag disables the check\&. This is purely for the internal use for
\fBgit\fR
\fBpull\fR
to communicate with
\fBgit\fR
\fBfetch\fR, and unless you are implementing your own Porcelain you are not supposed to use it\&.
.RE
.PP
\fB\-\-upload\-pack\fR \fI\fR
.RS 4
When given, and the repository to fetch from is handled by
\fBgit\fR
\fBfetch\-pack\fR,
\fB\-\-exec=\fR\fI\fR
is passed to the command to specify non\-default path for the command run on the other end\&.
.RE
.PP
\fB\-q\fR, \fB\-\-quiet\fR
.RS 4
Pass
\fB\-\-quiet\fR
to
\fBgit\-fetch\-pack\fR
and silence any other internally used git commands\&. Progress is not reported to the standard error stream\&.
.RE
.PP
\fB\-v\fR, \fB\-\-verbose\fR
.RS 4
Be verbose\&.
.RE
.PP
\fB\-\-progress\fR
.RS 4
Progress status is reported on the standard error stream by default when it is attached to a terminal, unless
\fB\-q\fR
is specified\&. This flag forces progress status even if the standard error stream is not directed to a terminal\&.
.RE
.PP
\fB\-o\fR \fI