1GIT-FETCH(1)                      Git Manual                      GIT-FETCH(1)
2
3
4

NAME

6       git-fetch - Download objects and refs from another repository
7

SYNOPSIS

9       git fetch [<options>] [<repository> [<refspec>...]]
10       git fetch [<options>] <group>
11       git fetch --multiple [<options>] [(<repository> | <group>)...]
12       git fetch --all [<options>]
13

DESCRIPTION

15       Fetch branches and/or tags (collectively, "refs") from one or more
16       other repositories, along with the objects necessary to complete their
17       histories. Remote-tracking branches are updated (see the description of
18       <refspec> below for ways to control this behavior).
19
20       By default, any tag that points into the histories being fetched is
21       also fetched; the effect is to fetch tags that point at branches that
22       you are interested in. This default behavior can be changed by using
23       the --tags or --no-tags options or by configuring remote.<name>.tagOpt.
24       By using a refspec that fetches tags explicitly, you can fetch tags
25       that do not point into branches you are interested in as well.
26
27       git fetch can fetch from either a single named repository or URL, or
28       from several repositories at once if <group> is given and there is a
29       remotes.<group> entry in the configuration file. (See git-config(1)).
30
31       When no remote is specified, by default the origin remote will be used,
32       unless there’s an upstream branch configured for the current branch.
33
34       The names of refs that are fetched, together with the object names they
35       point at, are written to .git/FETCH_HEAD. This information may be used
36       by scripts or other git commands, such as git-pull(1).
37

OPTIONS

39       --all
40           Fetch all remotes.
41
42       -a, --append
43           Append ref names and object names of fetched refs to the existing
44           contents of .git/FETCH_HEAD. Without this option old data in
45           .git/FETCH_HEAD will be overwritten.
46
47       --atomic
48           Use an atomic transaction to update local refs. Either all refs are
49           updated, or on error, no refs are updated.
50
51       --depth=<depth>
52           Limit fetching to the specified number of commits from the tip of
53           each remote branch history. If fetching to a shallow repository
54           created by git clone with --depth=<depth> option (see git-
55           clone(1)), deepen or shorten the history to the specified number of
56           commits. Tags for the deepened commits are not fetched.
57
58       --deepen=<depth>
59           Similar to --depth, except it specifies the number of commits from
60           the current shallow boundary instead of from the tip of each remote
61           branch history.
62
63       --shallow-since=<date>
64           Deepen or shorten the history of a shallow repository to include
65           all reachable commits after <date>.
66
67       --shallow-exclude=<revision>
68           Deepen or shorten the history of a shallow repository to exclude
69           commits reachable from a specified remote branch or tag. This
70           option can be specified multiple times.
71
72       --unshallow
73           If the source repository is complete, convert a shallow repository
74           to a complete one, removing all the limitations imposed by shallow
75           repositories.
76
77           If the source repository is shallow, fetch as much as possible so
78           that the current repository has the same history as the source
79           repository.
80
81       --update-shallow
82           By default when fetching from a shallow repository, git fetch
83           refuses refs that require updating .git/shallow. This option
84           updates .git/shallow and accepts such refs.
85
86       --negotiation-tip=<commit|glob>
87           By default, Git will report, to the server, commits reachable from
88           all local refs to find common commits in an attempt to reduce the
89           size of the to-be-received packfile. If specified, Git will only
90           report commits reachable from the given tips. This is useful to
91           speed up fetches when the user knows which local ref is likely to
92           have commits in common with the upstream ref being fetched.
93
94           This option may be specified more than once; if so, Git will report
95           commits reachable from any of the given commits.
96
97           The argument to this option may be a glob on ref names, a ref, or
98           the (possibly abbreviated) SHA-1 of a commit. Specifying a glob is
99           equivalent to specifying this option multiple times, one for each
100           matching ref name.
101
102           See also the fetch.negotiationAlgorithm and push.negotiate
103           configuration variables documented in git-config(1), and the
104           --negotiate-only option below.
105
106       --negotiate-only
107           Do not fetch anything from the server, and instead print the
108           ancestors of the provided --negotiation-tip=* arguments, which we
109           have in common with the server.
110
111           This is incompatible with --recurse-submodules=[yes|on-demand].
112           Internally this is used to implement the push.negotiate option, see
113           git-config(1).
114
115       --dry-run
116           Show what would be done, without making any changes.
117
118       --porcelain
119           Print the output to standard output in an easy-to-parse format for
120           scripts. See section OUTPUT in git-fetch(1) for details.
121
122           This is incompatible with --recurse-submodules=[yes|on-demand] and
123           takes precedence over the fetch.output config option.
124
125       --[no-]write-fetch-head
126           Write the list of remote refs fetched in the FETCH_HEAD file
127           directly under $GIT_DIR. This is the default. Passing
128           --no-write-fetch-head from the command line tells Git not to write
129           the file. Under --dry-run option, the file is never written.
130
131       -f, --force
132           When git fetch is used with <src>:<dst> refspec, it may refuse to
133           update the local branch as discussed in the <refspec> part below.
134           This option overrides that check.
135
136       -k, --keep
137           Keep downloaded pack.
138
139       --multiple
140           Allow several <repository> and <group> arguments to be specified.
141           No <refspec>s may be specified.
142
143       --[no-]auto-maintenance, --[no-]auto-gc
144           Run git maintenance run --auto at the end to perform automatic
145           repository maintenance if needed. (--[no-]auto-gc is a synonym.)
146           This is enabled by default.
147
148       --[no-]write-commit-graph
149           Write a commit-graph after fetching. This overrides the config
150           setting fetch.writeCommitGraph.
151
152       --prefetch
153           Modify the configured refspec to place all refs into the
154           refs/prefetch/ namespace. See the prefetch task in git-
155           maintenance(1).
156
157       -p, --prune
158           Before fetching, remove any remote-tracking references that no
159           longer exist on the remote. Tags are not subject to pruning if they
160           are fetched only because of the default tag auto-following or due
161           to a --tags option. However, if tags are fetched due to an explicit
162           refspec (either on the command line or in the remote configuration,
163           for example if the remote was cloned with the --mirror option),
164           then they are also subject to pruning. Supplying --prune-tags is a
165           shorthand for providing the tag refspec.
166
167           See the PRUNING section below for more details.
168
169       -P, --prune-tags
170           Before fetching, remove any local tags that no longer exist on the
171           remote if --prune is enabled. This option should be used more
172           carefully, unlike --prune it will remove any local references
173           (local tags) that have been created. This option is a shorthand for
174           providing the explicit tag refspec along with --prune, see the
175           discussion about that in its documentation.
176
177           See the PRUNING section below for more details.
178
179       -n, --no-tags
180           By default, tags that point at objects that are downloaded from the
181           remote repository are fetched and stored locally. This option
182           disables this automatic tag following. The default behavior for a
183           remote may be specified with the remote.<name>.tagOpt setting. See
184           git-config(1).
185
186       --refetch
187           Instead of negotiating with the server to avoid transferring
188           commits and associated objects that are already present locally,
189           this option fetches all objects as a fresh clone would. Use this to
190           reapply a partial clone filter from configuration or using
191           --filter= when the filter definition has changed. Automatic
192           post-fetch maintenance will perform object database pack
193           consolidation to remove any duplicate objects.
194
195       --refmap=<refspec>
196           When fetching refs listed on the command line, use the specified
197           refspec (can be given more than once) to map the refs to
198           remote-tracking branches, instead of the values of remote.*.fetch
199           configuration variables for the remote repository. Providing an
200           empty <refspec> to the --refmap option causes Git to ignore the
201           configured refspecs and rely entirely on the refspecs supplied as
202           command-line arguments. See section on "Configured Remote-tracking
203           Branches" for details.
204
205       -t, --tags
206           Fetch all tags from the remote (i.e., fetch remote tags refs/tags/*
207           into local tags with the same name), in addition to whatever else
208           would otherwise be fetched. Using this option alone does not
209           subject tags to pruning, even if --prune is used (though tags may
210           be pruned anyway if they are also the destination of an explicit
211           refspec; see --prune).
212
213       --recurse-submodules[=yes|on-demand|no]
214           This option controls if and under what conditions new commits of
215           submodules should be fetched too. When recursing through
216           submodules, git fetch always attempts to fetch "changed"
217           submodules, that is, a submodule that has commits that are
218           referenced by a newly fetched superproject commit but are missing
219           in the local submodule clone. A changed submodule can be fetched as
220           long as it is present locally e.g. in $GIT_DIR/modules/ (see
221           gitsubmodules(7)); if the upstream adds a new submodule, that
222           submodule cannot be fetched until it is cloned e.g. by git
223           submodule update.
224
225           When set to on-demand, only changed submodules are fetched. When
226           set to yes, all populated submodules are fetched and submodules
227           that are both unpopulated and changed are fetched. When set to no,
228           submodules are never fetched.
229
230           When unspecified, this uses the value of fetch.recurseSubmodules if
231           it is set (see git-config(1)), defaulting to on-demand if unset.
232           When this option is used without any value, it defaults to yes.
233
234       -j, --jobs=<n>
235           Number of parallel children to be used for all forms of fetching.
236
237           If the --multiple option was specified, the different remotes will
238           be fetched in parallel. If multiple submodules are fetched, they
239           will be fetched in parallel. To control them independently, use the
240           config settings fetch.parallel and submodule.fetchJobs (see git-
241           config(1)).
242
243           Typically, parallel recursive and multi-remote fetches will be
244           faster. By default fetches are performed sequentially, not in
245           parallel.
246
247       --no-recurse-submodules
248           Disable recursive fetching of submodules (this has the same effect
249           as using the --recurse-submodules=no option).
250
251       --set-upstream
252           If the remote is fetched successfully, add upstream (tracking)
253           reference, used by argument-less git-pull(1) and other commands.
254           For more information, see branch.<name>.merge and
255           branch.<name>.remote in git-config(1).
256
257       --submodule-prefix=<path>
258           Prepend <path> to paths printed in informative messages such as
259           "Fetching submodule foo". This option is used internally when
260           recursing over submodules.
261
262       --recurse-submodules-default=[yes|on-demand]
263           This option is used internally to temporarily provide a
264           non-negative default value for the --recurse-submodules option. All
265           other methods of configuring fetch’s submodule recursion (such as
266           settings in gitmodules(5) and git-config(1)) override this option,
267           as does specifying --[no-]recurse-submodules directly.
268
269       -u, --update-head-ok
270           By default git fetch refuses to update the head which corresponds
271           to the current branch. This flag disables the check. This is purely
272           for the internal use for git pull to communicate with git fetch,
273           and unless you are implementing your own Porcelain you are not
274           supposed to use it.
275
276       --upload-pack <upload-pack>
277           When given, and the repository to fetch from is handled by git
278           fetch-pack, --exec=<upload-pack> is passed to the command to
279           specify non-default path for the command run on the other end.
280
281       -q, --quiet
282           Pass --quiet to git-fetch-pack and silence any other internally
283           used git commands. Progress is not reported to the standard error
284           stream.
285
286       -v, --verbose
287           Be verbose.
288
289       --progress
290           Progress status is reported on the standard error stream by default
291           when it is attached to a terminal, unless -q is specified. This
292           flag forces progress status even if the standard error stream is
293           not directed to a terminal.
294
295       -o <option>, --server-option=<option>
296           Transmit the given string to the server when communicating using
297           protocol version 2. The given string must not contain a NUL or LF
298           character. The server’s handling of server options, including
299           unknown ones, is server-specific. When multiple
300           --server-option=<option> are given, they are all sent to the other
301           side in the order listed on the command line.
302
303       --show-forced-updates
304           By default, git checks if a branch is force-updated during fetch.
305           This can be disabled through fetch.showForcedUpdates, but the
306           --show-forced-updates option guarantees this check occurs. See git-
307           config(1).
308
309       --no-show-forced-updates
310           By default, git checks if a branch is force-updated during fetch.
311           Pass --no-show-forced-updates or set fetch.showForcedUpdates to
312           false to skip this check for performance reasons. If used during
313           git-pull the --ff-only option will still check for forced updates
314           before attempting a fast-forward update. See git-config(1).
315
316       -4, --ipv4
317           Use IPv4 addresses only, ignoring IPv6 addresses.
318
319       -6, --ipv6
320           Use IPv6 addresses only, ignoring IPv4 addresses.
321
322       <repository>
323           The "remote" repository that is the source of a fetch or pull
324           operation. This parameter can be either a URL (see the section GIT
325           URLS below) or the name of a remote (see the section REMOTES
326           below).
327
328       <group>
329           A name referring to a list of repositories as the value of
330           remotes.<group> in the configuration file. (See git-config(1)).
331
332       <refspec>
333           Specifies which refs to fetch and which local refs to update. When
334           no <refspec>s appear on the command line, the refs to fetch are
335           read from remote.<repository>.fetch variables instead (see
336           CONFIGURED REMOTE-TRACKING BRANCHES below).
337
338           The format of a <refspec> parameter is an optional plus +, followed
339           by the source <src>, followed by a colon :, followed by the
340           destination ref <dst>. The colon can be omitted when <dst> is
341           empty. <src> is typically a ref, but it can also be a fully spelled
342           hex object name.
343
344           A <refspec> may contain a * in its <src> to indicate a simple
345           pattern match. Such a refspec functions like a glob that matches
346           any ref with the same prefix. A pattern <refspec> must have a * in
347           both the <src> and <dst>. It will map refs to the destination by
348           replacing the * with the contents matched from the source.
349
350           If a refspec is prefixed by ^, it will be interpreted as a negative
351           refspec. Rather than specifying which refs to fetch or which local
352           refs to update, such a refspec will instead specify refs to
353           exclude. A ref will be considered to match if it matches at least
354           one positive refspec, and does not match any negative refspec.
355           Negative refspecs can be useful to restrict the scope of a pattern
356           refspec so that it will not include specific refs. Negative
357           refspecs can themselves be pattern refspecs. However, they may only
358           contain a <src> and do not specify a <dst>. Fully spelled out hex
359           object names are also not supported.
360
361           tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; it
362           requests fetching everything up to the given tag.
363
364           The remote ref that matches <src> is fetched, and if <dst> is not
365           an empty string, an attempt is made to update the local ref that
366           matches it.
367
368           Whether that update is allowed without --force depends on the ref
369           namespace it’s being fetched to, the type of object being fetched,
370           and whether the update is considered to be a fast-forward.
371           Generally, the same rules apply for fetching as when pushing, see
372           the <refspec>...  section of git-push(1) for what those are.
373           Exceptions to those rules particular to git fetch are noted below.
374
375           Until Git version 2.20, and unlike when pushing with git-push(1),
376           any updates to refs/tags/* would be accepted without + in the
377           refspec (or --force). When fetching, we promiscuously considered
378           all tag updates from a remote to be forced fetches. Since Git
379           version 2.20, fetching to update refs/tags/* works the same way as
380           when pushing. I.e. any updates will be rejected without + in the
381           refspec (or --force).
382
383           Unlike when pushing with git-push(1), any updates outside of
384           refs/{tags,heads}/* will be accepted without + in the refspec (or
385           --force), whether that’s swapping e.g. a tree object for a blob, or
386           a commit for another commit that doesn’t have the previous commit
387           as an ancestor etc.
388
389           Unlike when pushing with git-push(1), there is no configuration
390           which’ll amend these rules, and nothing like a pre-fetch hook
391           analogous to the pre-receive hook.
392
393           As with pushing with git-push(1), all of the rules described above
394           about what’s not allowed as an update can be overridden by adding
395           an optional leading + to a refspec (or using the --force command
396           line option). The only exception to this is that no amount of
397           forcing will make the refs/heads/* namespace accept a non-commit
398           object.
399
400               Note
401               When the remote branch you want to fetch is known to be rewound
402               and rebased regularly, it is expected that its new tip will not
403               be a descendant of its previous tip (as stored in your
404               remote-tracking branch the last time you fetched). You would
405               want to use the + sign to indicate non-fast-forward updates
406               will be needed for such branches. There is no way to determine
407               or declare that a branch will be made available in a repository
408               with this behavior; the pulling user simply must know this is
409               the expected usage pattern for a branch.
410
411       --stdin
412           Read refspecs, one per line, from stdin in addition to those
413           provided as arguments. The "tag <name>" format is not supported.
414

GIT URLS

416       In general, URLs contain information about the transport protocol, the
417       address of the remote server, and the path to the repository. Depending
418       on the transport protocol, some of this information may be absent.
419
420       Git supports ssh, git, http, and https protocols (in addition, ftp and
421       ftps can be used for fetching, but this is inefficient and deprecated;
422       do not use them).
423
424       The native transport (i.e. git:// URL) does no authentication and
425       should be used with caution on unsecured networks.
426
427       The following syntaxes may be used with them:
428
429       •   ssh://[user@]host.xz[:port]/path/to/repo.git/
430
431       •   git://host.xz[:port]/path/to/repo.git/
432
433       •   http[s]://host.xz[:port]/path/to/repo.git/
434
435       •   ftp[s]://host.xz[:port]/path/to/repo.git/
436
437       An alternative scp-like syntax may also be used with the ssh protocol:
438
439       •   [user@]host.xz:path/to/repo.git/
440
441       This syntax is only recognized if there are no slashes before the first
442       colon. This helps differentiate a local path that contains a colon. For
443       example the local path foo:bar could be specified as an absolute path
444       or ./foo:bar to avoid being misinterpreted as an ssh url.
445
446       The ssh and git protocols additionally support ~username expansion:
447
448       •   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
449
450       •   git://host.xz[:port]/~[user]/path/to/repo.git/
451
452       •   [user@]host.xz:/~[user]/path/to/repo.git/
453
454       For local repositories, also supported by Git natively, the following
455       syntaxes may be used:
456
457       •   /path/to/repo.git/
458
459       •   file:///path/to/repo.git/
460
461       These two syntaxes are mostly equivalent, except when cloning, when the
462       former implies --local option. See git-clone(1) for details.
463
464       git clone, git fetch and git pull, but not git push, will also accept a
465       suitable bundle file. See git-bundle(1).
466
467       When Git doesn’t know how to handle a certain transport protocol, it
468       attempts to use the remote-<transport> remote helper, if one exists. To
469       explicitly request a remote helper, the following syntax may be used:
470
471       •   <transport>::<address>
472
473       where <address> may be a path, a server and path, or an arbitrary
474       URL-like string recognized by the specific remote helper being invoked.
475       See gitremote-helpers(7) for details.
476
477       If there are a large number of similarly-named remote repositories and
478       you want to use a different format for them (such that the URLs you use
479       will be rewritten into URLs that work), you can create a configuration
480       section of the form:
481
482                   [url "<actual url base>"]
483                           insteadOf = <other url base>
484
485       For example, with this:
486
487                   [url "git://git.host.xz/"]
488                           insteadOf = host.xz:/path/to/
489                           insteadOf = work:
490
491       a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
492       rewritten in any context that takes a URL to be
493       "git://git.host.xz/repo.git".
494
495       If you want to rewrite URLs for push only, you can create a
496       configuration section of the form:
497
498                   [url "<actual url base>"]
499                           pushInsteadOf = <other url base>
500
501       For example, with this:
502
503                   [url "ssh://example.org/"]
504                           pushInsteadOf = git://example.org/
505
506       a URL like "git://example.org/path/to/repo.git" will be rewritten to
507       "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
508       use the original URL.
509

REMOTES

511       The name of one of the following can be used instead of a URL as
512       <repository> argument:
513
514       •   a remote in the Git configuration file: $GIT_DIR/config,
515
516       •   a file in the $GIT_DIR/remotes directory, or
517
518       •   a file in the $GIT_DIR/branches directory.
519
520       All of these also allow you to omit the refspec from the command line
521       because they each contain a refspec which git will use by default.
522
523   Named remote in configuration file
524       You can choose to provide the name of a remote which you had previously
525       configured using git-remote(1), git-config(1) or even by a manual edit
526       to the $GIT_DIR/config file. The URL of this remote will be used to
527       access the repository. The refspec of this remote will be used by
528       default when you do not provide a refspec on the command line. The
529       entry in the config file would appear like this:
530
531                   [remote "<name>"]
532                           url = <URL>
533                           pushurl = <pushurl>
534                           push = <refspec>
535                           fetch = <refspec>
536
537       The <pushurl> is used for pushes only. It is optional and defaults to
538       <URL>. Pushing to a remote affects all defined pushurls or all defined
539       urls if no pushurls are defined. Fetch, however, will only fetch from
540       the first defined url if multiple urls are defined.
541
542   Named file in $GIT_DIR/remotes
543       You can choose to provide the name of a file in $GIT_DIR/remotes. The
544       URL in this file will be used to access the repository. The refspec in
545       this file will be used as default when you do not provide a refspec on
546       the command line. This file should have the following format:
547
548                   URL: one of the above URL formats
549                   Push: <refspec>
550                   Pull: <refspec>
551
552       Push: lines are used by git push and Pull: lines are used by git pull
553       and git fetch. Multiple Push: and Pull: lines may be specified for
554       additional branch mappings.
555
556   Named file in $GIT_DIR/branches
557       You can choose to provide the name of a file in $GIT_DIR/branches. The
558       URL in this file will be used to access the repository. This file
559       should have the following format:
560
561                   <URL>#<head>
562
563       <URL> is required; #<head> is optional.
564
565       Depending on the operation, git will use one of the following refspecs,
566       if you don’t provide one on the command line. <branch> is the name of
567       this file in $GIT_DIR/branches and <head> defaults to master.
568
569       git fetch uses:
570
571                   refs/heads/<head>:refs/heads/<branch>
572
573       git push uses:
574
575                   HEAD:refs/heads/<head>
576

CONFIGURED REMOTE-TRACKING BRANCHES

578       You often interact with the same remote repository by regularly and
579       repeatedly fetching from it. In order to keep track of the progress of
580       such a remote repository, git fetch allows you to configure
581       remote.<repository>.fetch configuration variables.
582
583       Typically such a variable may look like this:
584
585           [remote "origin"]
586                   fetch = +refs/heads/*:refs/remotes/origin/*
587
588       This configuration is used in two ways:
589
590       •   When git fetch is run without specifying what branches and/or tags
591           to fetch on the command line, e.g.  git fetch origin or git fetch,
592           remote.<repository>.fetch values are used as the refspecs—they
593           specify which refs to fetch and which local refs to update. The
594           example above will fetch all branches that exist in the origin
595           (i.e. any ref that matches the left-hand side of the value,
596           refs/heads/*) and update the corresponding remote-tracking branches
597           in the refs/remotes/origin/* hierarchy.
598
599       •   When git fetch is run with explicit branches and/or tags to fetch
600           on the command line, e.g.  git fetch origin master, the <refspec>s
601           given on the command line determine what are to be fetched (e.g.
602           master in the example, which is a short-hand for master:, which in
603           turn means "fetch the master branch but I do not explicitly say
604           what remote-tracking branch to update with it from the command
605           line"), and the example command will fetch only the master branch.
606           The remote.<repository>.fetch values determine which
607           remote-tracking branch, if any, is updated. When used in this way,
608           the remote.<repository>.fetch values do not have any effect in
609           deciding what gets fetched (i.e. the values are not used as
610           refspecs when the command-line lists refspecs); they are only used
611           to decide where the refs that are fetched are stored by acting as a
612           mapping.
613
614       The latter use of the remote.<repository>.fetch values can be
615       overridden by giving the --refmap=<refspec> parameter(s) on the command
616       line.
617

PRUNING

619       Git has a default disposition of keeping data unless it’s explicitly
620       thrown away; this extends to holding onto local references to branches
621       on remotes that have themselves deleted those branches.
622
623       If left to accumulate, these stale references might make performance
624       worse on big and busy repos that have a lot of branch churn, and e.g.
625       make the output of commands like git branch -a --contains <commit>
626       needlessly verbose, as well as impacting anything else that’ll work
627       with the complete set of known references.
628
629       These remote-tracking references can be deleted as a one-off with
630       either of:
631
632           # While fetching
633           $ git fetch --prune <name>
634
635           # Only prune, don't fetch
636           $ git remote prune <name>
637
638       To prune references as part of your normal workflow without needing to
639       remember to run that, set fetch.prune globally, or remote.<name>.prune
640       per-remote in the config. See git-config(1).
641
642       Here’s where things get tricky and more specific. The pruning feature
643       doesn’t actually care about branches, instead it’ll prune local ←→
644       remote-references as a function of the refspec of the remote (see
645       <refspec> and CONFIGURED REMOTE-TRACKING BRANCHES above).
646
647       Therefore if the refspec for the remote includes e.g.
648       refs/tags/*:refs/tags/*, or you manually run e.g. git fetch --prune
649       <name> "refs/tags/*:refs/tags/*" it won’t be stale remote tracking
650       branches that are deleted, but any local tag that doesn’t exist on the
651       remote.
652
653       This might not be what you expect, i.e. you want to prune remote
654       <name>, but also explicitly fetch tags from it, so when you fetch from
655       it you delete all your local tags, most of which may not have come from
656       the <name> remote in the first place.
657
658       So be careful when using this with a refspec like
659       refs/tags/*:refs/tags/*, or any other refspec which might map
660       references from multiple remotes to the same local namespace.
661
662       Since keeping up-to-date with both branches and tags on the remote is a
663       common use-case the --prune-tags option can be supplied along with
664       --prune to prune local tags that don’t exist on the remote, and
665       force-update those tags that differ. Tag pruning can also be enabled
666       with fetch.pruneTags or remote.<name>.pruneTags in the config. See git-
667       config(1).
668
669       The --prune-tags option is equivalent to having refs/tags/*:refs/tags/*
670       declared in the refspecs of the remote. This can lead to some seemingly
671       strange interactions:
672
673           # These both fetch tags
674           $ git fetch --no-tags origin 'refs/tags/*:refs/tags/*'
675           $ git fetch --no-tags --prune-tags origin
676
677       The reason it doesn’t error out when provided without --prune or its
678       config versions is for flexibility of the configured versions, and to
679       maintain a 1=1 mapping between what the command line flags do, and what
680       the configuration versions do.
681
682       It’s reasonable to e.g. configure fetch.pruneTags=true in ~/.gitconfig
683       to have tags pruned whenever git fetch --prune is run, without making
684       every invocation of git fetch without --prune an error.
685
686       Pruning tags with --prune-tags also works when fetching a URL instead
687       of a named remote. These will all prune tags not found on origin:
688
689           $ git fetch origin --prune --prune-tags
690           $ git fetch origin --prune 'refs/tags/*:refs/tags/*'
691           $ git fetch <url of origin> --prune --prune-tags
692           $ git fetch <url of origin> --prune 'refs/tags/*:refs/tags/*'
693

OUTPUT

695       The output of "git fetch" depends on the transport method used; this
696       section describes the output when fetching over the Git protocol
697       (either locally or via ssh) and Smart HTTP protocol.
698
699       The status of the fetch is output in tabular form, with each line
700       representing the status of a single ref. Each line is of the form:
701
702            <flag> <summary> <from> -> <to> [<reason>]
703
704       When using --porcelain, the output format is intended to be
705       machine-parseable. In contrast to the human-readable output formats it
706       thus prints to standard output instead of standard error. Each line is
707       of the form:
708
709           <flag> <old-object-id> <new-object-id> <local-reference>
710
711       The status of up-to-date refs is shown only if the --verbose option is
712       used.
713
714       In compact output mode, specified with configuration variable
715       fetch.output, if either entire <from> or <to> is found in the other
716       string, it will be substituted with * in the other string. For example,
717       master -> origin/master becomes master -> origin/*.
718
719       flag
720           A single character indicating the status of the ref:
721
722           (space)
723               for a successfully fetched fast-forward;
724
725           +
726               for a successful forced update;
727
728           -
729               for a successfully pruned ref;
730
731           t
732               for a successful tag update;
733
734           *
735               for a successfully fetched new ref;
736
737           !
738               for a ref that was rejected or failed to update; and
739
740           =
741               for a ref that was up to date and did not need fetching.
742
743       summary
744           For a successfully fetched ref, the summary shows the old and new
745           values of the ref in a form suitable for using as an argument to
746           git log (this is <old>..<new> in most cases, and <old>...<new> for
747           forced non-fast-forward updates).
748
749       from
750           The name of the remote ref being fetched from, minus its
751           refs/<type>/ prefix. In the case of deletion, the name of the
752           remote ref is "(none)".
753
754       to
755           The name of the local ref being updated, minus its refs/<type>/
756           prefix.
757
758       reason
759           A human-readable explanation. In the case of successfully fetched
760           refs, no explanation is needed. For a failed ref, the reason for
761           failure is described.
762

EXAMPLES

764       •   Update the remote-tracking branches:
765
766               $ git fetch origin
767
768           The above command copies all branches from the remote refs/heads/
769           namespace and stores them to the local refs/remotes/origin/
770           namespace, unless the remote.<repository>.fetch option is used to
771           specify a non-default refspec.
772
773       •   Using refspecs explicitly:
774
775               $ git fetch origin +seen:seen maint:tmp
776
777           This updates (or creates, as necessary) branches seen and tmp in
778           the local repository by fetching from the branches (respectively)
779           seen and maint from the remote repository.
780
781           The seen branch will be updated even if it does not fast-forward,
782           because it is prefixed with a plus sign; tmp will not be.
783
784       •   Peek at a remote’s branch, without configuring the remote in your
785           local repository:
786
787               $ git fetch git://git.kernel.org/pub/scm/git/git.git maint
788               $ git log FETCH_HEAD
789
790           The first command fetches the maint branch from the repository at
791           git://git.kernel.org/pub/scm/git/git.git and the second command
792           uses FETCH_HEAD to examine the branch with git-log(1). The fetched
793           objects will eventually be removed by git’s built-in housekeeping
794           (see git-gc(1)).
795

SECURITY

797       The fetch and push protocols are not designed to prevent one side from
798       stealing data from the other repository that was not intended to be
799       shared. If you have private data that you need to protect from a
800       malicious peer, your best option is to store it in another repository.
801       This applies to both clients and servers. In particular, namespaces on
802       a server are not effective for read access control; you should only
803       grant read access to a namespace to clients that you would trust with
804       read access to the entire repository.
805
806       The known attack vectors are as follows:
807
808        1. The victim sends "have" lines advertising the IDs of objects it has
809           that are not explicitly intended to be shared but can be used to
810           optimize the transfer if the peer also has them. The attacker
811           chooses an object ID X to steal and sends a ref to X, but isn’t
812           required to send the content of X because the victim already has
813           it. Now the victim believes that the attacker has X, and it sends
814           the content of X back to the attacker later. (This attack is most
815           straightforward for a client to perform on a server, by creating a
816           ref to X in the namespace the client has access to and then
817           fetching it. The most likely way for a server to perform it on a
818           client is to "merge" X into a public branch and hope that the user
819           does additional work on this branch and pushes it back to the
820           server without noticing the merge.)
821
822        2. As in #1, the attacker chooses an object ID X to steal. The victim
823           sends an object Y that the attacker already has, and the attacker
824           falsely claims to have X and not Y, so the victim sends Y as a
825           delta against X. The delta reveals regions of X that are similar to
826           Y to the attacker.
827

CONFIGURATION

829       Everything below this line in this section is selectively included from
830       the git-config(1) documentation. The content is the same as what’s
831       found there:
832
833       fetch.recurseSubmodules
834           This option controls whether git fetch (and the underlying fetch in
835           git pull) will recursively fetch into populated submodules. This
836           option can be set either to a boolean value or to on-demand.
837           Setting it to a boolean changes the behavior of fetch and pull to
838           recurse unconditionally into submodules when set to true or to not
839           recurse at all when set to false. When set to on-demand, fetch and
840           pull will only recurse into a populated submodule when its
841           superproject retrieves a commit that updates the submodule’s
842           reference. Defaults to on-demand, or to the value of
843           submodule.recurse if set.
844
845       fetch.fsckObjects
846           If it is set to true, git-fetch-pack will check all fetched
847           objects. See transfer.fsckObjects for what’s checked. Defaults to
848           false. If not set, the value of transfer.fsckObjects is used
849           instead.
850
851       fetch.fsck.<msg-id>
852           Acts like fsck.<msg-id>, but is used by git-fetch-pack(1) instead
853           of git-fsck(1). See the fsck.<msg-id> documentation for details.
854
855       fetch.fsck.skipList
856           Acts like fsck.skipList, but is used by git-fetch-pack(1) instead
857           of git-fsck(1). See the fsck.skipList documentation for details.
858
859       fetch.unpackLimit
860           If the number of objects fetched over the Git native transfer is
861           below this limit, then the objects will be unpacked into loose
862           object files. However if the number of received objects equals or
863           exceeds this limit then the received pack will be stored as a pack,
864           after adding any missing delta bases. Storing the pack from a push
865           can make the push operation complete faster, especially on slow
866           filesystems. If not set, the value of transfer.unpackLimit is used
867           instead.
868
869       fetch.prune
870           If true, fetch will automatically behave as if the --prune option
871           was given on the command line. See also remote.<name>.prune and the
872           PRUNING section of git-fetch(1).
873
874       fetch.pruneTags
875           If true, fetch will automatically behave as if the
876           refs/tags/*:refs/tags/* refspec was provided when pruning, if not
877           set already. This allows for setting both this option and
878           fetch.prune to maintain a 1=1 mapping to upstream refs. See also
879           remote.<name>.pruneTags and the PRUNING section of git-fetch(1).
880
881       fetch.output
882           Control how ref update status is printed. Valid values are full and
883           compact. Default value is full. See the OUTPUT section in git-
884           fetch(1) for details.
885
886       fetch.negotiationAlgorithm
887           Control how information about the commits in the local repository
888           is sent when negotiating the contents of the packfile to be sent by
889           the server. Set to "consecutive" to use an algorithm that walks
890           over consecutive commits checking each one. Set to "skipping" to
891           use an algorithm that skips commits in an effort to converge
892           faster, but may result in a larger-than-necessary packfile; or set
893           to "noop" to not send any information at all, which will almost
894           certainly result in a larger-than-necessary packfile, but will skip
895           the negotiation step. Set to "default" to override settings made
896           previously and use the default behaviour. The default is normally
897           "consecutive", but if feature.experimental is true, then the
898           default is "skipping". Unknown values will cause git fetch to error
899           out.
900
901           See also the --negotiate-only and --negotiation-tip options to git-
902           fetch(1).
903
904       fetch.showForcedUpdates
905           Set to false to enable --no-show-forced-updates in git-fetch(1) and
906           git-pull(1) commands. Defaults to true.
907
908       fetch.parallel
909           Specifies the maximal number of fetch operations to be run in
910           parallel at a time (submodules, or remotes when the --multiple
911           option of git-fetch(1) is in effect).
912
913           A value of 0 will give some reasonable default. If unset, it
914           defaults to 1.
915
916           For submodules, this setting can be overridden using the
917           submodule.fetchJobs config setting.
918
919       fetch.writeCommitGraph
920           Set to true to write a commit-graph after every git fetch command
921           that downloads a pack-file from a remote. Using the --split option,
922           most executions will create a very small commit-graph file on top
923           of the existing commit-graph file(s). Occasionally, these files
924           will merge and the write may take longer. Having an updated
925           commit-graph file helps performance of many Git commands, including
926           git merge-base, git push -f, and git log --graph. Defaults to
927           false.
928
929       fetch.bundleURI
930           This value stores a URI for downloading Git object data from a
931           bundle URI before performing an incremental fetch from the origin
932           Git server. This is similar to how the --bundle-uri option behaves
933           in git-clone(1).  git clone --bundle-uri will set the
934           fetch.bundleURI value if the supplied bundle URI contains a bundle
935           list that is organized for incremental fetches.
936
937           If you modify this value and your repository has a
938           fetch.bundleCreationToken value, then remove that
939           fetch.bundleCreationToken value before fetching from the new bundle
940           URI.
941
942       fetch.bundleCreationToken
943           When using fetch.bundleURI to fetch incrementally from a bundle
944           list that uses the "creationToken" heuristic, this config value
945           stores the maximum creationToken value of the downloaded bundles.
946           This value is used to prevent downloading bundles in the future if
947           the advertised creationToken is not strictly larger than this
948           value.
949
950           The creation token values are chosen by the provider serving the
951           specific bundle URI. If you modify the URI at fetch.bundleURI, then
952           be sure to remove the value for the fetch.bundleCreationToken value
953           before fetching.
954

BUGS

956       Using --recurse-submodules can only fetch new commits in submodules
957       that are present locally e.g. in $GIT_DIR/modules/. If the upstream
958       adds a new submodule, that submodule cannot be fetched until it is
959       cloned e.g. by git submodule update. This is expected to be fixed in a
960       future Git version.
961

SEE ALSO

963       git-pull(1)
964

GIT

966       Part of the git(1) suite
967
968
969
970Git 2.43.0                        11/20/2023                      GIT-FETCH(1)
Impressum