1GIT-FETCH(1) Git Manual GIT-FETCH(1)
2
3
4
6 git-fetch - Download objects and refs from another repository
7
9 git fetch [<options>] [<repository> [<refspec>...]]
10 git fetch [<options>] <group>
11 git fetch --multiple [<options>] [(<repository> | <group>)...]
12 git fetch --all [<options>]
13
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
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 accept 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 Internally this is used to implement the push.negotiate option, see
112 git-config(1).
113
114 --dry-run
115 Show what would be done, without making any changes.
116
117 --[no-]write-fetch-head
118 Write the list of remote refs fetched in the FETCH_HEAD file
119 directly under $GIT_DIR. This is the default. Passing
120 --no-write-fetch-head from the command line tells Git not to write
121 the file. Under --dry-run option, the file is never written.
122
123 -f, --force
124 When git fetch is used with <src>:<dst> refspec it may refuse to
125 update the local branch as discussed in the <refspec> part below.
126 This option overrides that check.
127
128 -k, --keep
129 Keep downloaded pack.
130
131 --multiple
132 Allow several <repository> and <group> arguments to be specified.
133 No <refspec>s may be specified.
134
135 --[no-]auto-maintenance, --[no-]auto-gc
136 Run git maintenance run --auto at the end to perform automatic
137 repository maintenance if needed. (--[no-]auto-gc is a synonym.)
138 This is enabled by default.
139
140 --[no-]write-commit-graph
141 Write a commit-graph after fetching. This overrides the config
142 setting fetch.writeCommitGraph.
143
144 --prefetch
145 Modify the configured refspec to place all refs into the
146 refs/prefetch/ namespace. See the prefetch task in git-
147 maintenance(1).
148
149 -p, --prune
150 Before fetching, remove any remote-tracking references that no
151 longer exist on the remote. Tags are not subject to pruning if they
152 are fetched only because of the default tag auto-following or due
153 to a --tags option. However, if tags are fetched due to an explicit
154 refspec (either on the command line or in the remote configuration,
155 for example if the remote was cloned with the --mirror option),
156 then they are also subject to pruning. Supplying --prune-tags is a
157 shorthand for providing the tag refspec.
158
159 See the PRUNING section below for more details.
160
161 -P, --prune-tags
162 Before fetching, remove any local tags that no longer exist on the
163 remote if --prune is enabled. This option should be used more
164 carefully, unlike --prune it will remove any local references
165 (local tags) that have been created. This option is a shorthand for
166 providing the explicit tag refspec along with --prune, see the
167 discussion about that in its documentation.
168
169 See the PRUNING section below for more details.
170
171 -n, --no-tags
172 By default, tags that point at objects that are downloaded from the
173 remote repository are fetched and stored locally. This option
174 disables this automatic tag following. The default behavior for a
175 remote may be specified with the remote.<name>.tagOpt setting. See
176 git-config(1).
177
178 --refmap=<refspec>
179 When fetching refs listed on the command line, use the specified
180 refspec (can be given more than once) to map the refs to
181 remote-tracking branches, instead of the values of remote.*.fetch
182 configuration variables for the remote repository. Providing an
183 empty <refspec> to the --refmap option causes Git to ignore the
184 configured refspecs and rely entirely on the refspecs supplied as
185 command-line arguments. See section on "Configured Remote-tracking
186 Branches" for details.
187
188 -t, --tags
189 Fetch all tags from the remote (i.e., fetch remote tags refs/tags/*
190 into local tags with the same name), in addition to whatever else
191 would otherwise be fetched. Using this option alone does not
192 subject tags to pruning, even if --prune is used (though tags may
193 be pruned anyway if they are also the destination of an explicit
194 refspec; see --prune).
195
196 --recurse-submodules[=yes|on-demand|no]
197 This option controls if and under what conditions new commits of
198 populated submodules should be fetched too. It can be used as a
199 boolean option to completely disable recursion when set to no or to
200 unconditionally recurse into all populated submodules when set to
201 yes, which is the default when this option is used without any
202 value. Use on-demand to only recurse into a populated submodule
203 when the superproject retrieves a commit that updates the
204 submodule’s reference to a commit that isn’t already in the local
205 submodule clone. By default, on-demand is used, unless
206 fetch.recurseSubmodules is set (see git-config(1)).
207
208 -j, --jobs=<n>
209 Number of parallel children to be used for all forms of fetching.
210
211 If the --multiple option was specified, the different remotes will
212 be fetched in parallel. If multiple submodules are fetched, they
213 will be fetched in parallel. To control them independently, use the
214 config settings fetch.parallel and submodule.fetchJobs (see git-
215 config(1)).
216
217 Typically, parallel recursive and multi-remote fetches will be
218 faster. By default fetches are performed sequentially, not in
219 parallel.
220
221 --no-recurse-submodules
222 Disable recursive fetching of submodules (this has the same effect
223 as using the --recurse-submodules=no option).
224
225 --set-upstream
226 If the remote is fetched successfully, add upstream (tracking)
227 reference, used by argument-less git-pull(1) and other commands.
228 For more information, see branch.<name>.merge and
229 branch.<name>.remote in git-config(1).
230
231 --submodule-prefix=<path>
232 Prepend <path> to paths printed in informative messages such as
233 "Fetching submodule foo". This option is used internally when
234 recursing over submodules.
235
236 --recurse-submodules-default=[yes|on-demand]
237 This option is used internally to temporarily provide a
238 non-negative default value for the --recurse-submodules option. All
239 other methods of configuring fetch’s submodule recursion (such as
240 settings in gitmodules(5) and git-config(1)) override this option,
241 as does specifying --[no-]recurse-submodules directly.
242
243 -u, --update-head-ok
244 By default git fetch refuses to update the head which corresponds
245 to the current branch. This flag disables the check. This is purely
246 for the internal use for git pull to communicate with git fetch,
247 and unless you are implementing your own Porcelain you are not
248 supposed to use it.
249
250 --upload-pack <upload-pack>
251 When given, and the repository to fetch from is handled by git
252 fetch-pack, --exec=<upload-pack> is passed to the command to
253 specify non-default path for the command run on the other end.
254
255 -q, --quiet
256 Pass --quiet to git-fetch-pack and silence any other internally
257 used git commands. Progress is not reported to the standard error
258 stream.
259
260 -v, --verbose
261 Be verbose.
262
263 --progress
264 Progress status is reported on the standard error stream by default
265 when it is attached to a terminal, unless -q is specified. This
266 flag forces progress status even if the standard error stream is
267 not directed to a terminal.
268
269 -o <option>, --server-option=<option>
270 Transmit the given string to the server when communicating using
271 protocol version 2. The given string must not contain a NUL or LF
272 character. The server’s handling of server options, including
273 unknown ones, is server-specific. When multiple
274 --server-option=<option> are given, they are all sent to the other
275 side in the order listed on the command line.
276
277 --show-forced-updates
278 By default, git checks if a branch is force-updated during fetch.
279 This can be disabled through fetch.showForcedUpdates, but the
280 --show-forced-updates option guarantees this check occurs. See git-
281 config(1).
282
283 --no-show-forced-updates
284 By default, git checks if a branch is force-updated during fetch.
285 Pass --no-show-forced-updates or set fetch.showForcedUpdates to
286 false to skip this check for performance reasons. If used during
287 git-pull the --ff-only option will still check for forced updates
288 before attempting a fast-forward update. See git-config(1).
289
290 -4, --ipv4
291 Use IPv4 addresses only, ignoring IPv6 addresses.
292
293 -6, --ipv6
294 Use IPv6 addresses only, ignoring IPv4 addresses.
295
296 <repository>
297 The "remote" repository that is the source of a fetch or pull
298 operation. This parameter can be either a URL (see the section GIT
299 URLS below) or the name of a remote (see the section REMOTES
300 below).
301
302 <group>
303 A name referring to a list of repositories as the value of
304 remotes.<group> in the configuration file. (See git-config(1)).
305
306 <refspec>
307 Specifies which refs to fetch and which local refs to update. When
308 no <refspec>s appear on the command line, the refs to fetch are
309 read from remote.<repository>.fetch variables instead (see
310 CONFIGURED REMOTE-TRACKING BRANCHES below).
311
312 The format of a <refspec> parameter is an optional plus +, followed
313 by the source <src>, followed by a colon :, followed by the
314 destination ref <dst>. The colon can be omitted when <dst> is
315 empty. <src> is typically a ref, but it can also be a fully spelled
316 hex object name.
317
318 A <refspec> may contain a * in its <src> to indicate a simple
319 pattern match. Such a refspec functions like a glob that matches
320 any ref with the same prefix. A pattern <refspec> must have a * in
321 both the <src> and <dst>. It will map refs to the destination by
322 replacing the * with the contents matched from the source.
323
324 If a refspec is prefixed by ^, it will be interpreted as a negative
325 refspec. Rather than specifying which refs to fetch or which local
326 refs to update, such a refspec will instead specify refs to
327 exclude. A ref will be considered to match if it matches at least
328 one positive refspec, and does not match any negative refspec.
329 Negative refspecs can be useful to restrict the scope of a pattern
330 refspec so that it will not include specific refs. Negative
331 refspecs can themselves be pattern refspecs. However, they may only
332 contain a <src> and do not specify a <dst>. Fully spelled out hex
333 object names are also not supported.
334
335 tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; it
336 requests fetching everything up to the given tag.
337
338 The remote ref that matches <src> is fetched, and if <dst> is not
339 an empty string, an attempt is made to update the local ref that
340 matches it.
341
342 Whether that update is allowed without --force depends on the ref
343 namespace it’s being fetched to, the type of object being fetched,
344 and whether the update is considered to be a fast-forward.
345 Generally, the same rules apply for fetching as when pushing, see
346 the <refspec>... section of git-push(1) for what those are.
347 Exceptions to those rules particular to git fetch are noted below.
348
349 Until Git version 2.20, and unlike when pushing with git-push(1),
350 any updates to refs/tags/* would be accepted without + in the
351 refspec (or --force). When fetching, we promiscuously considered
352 all tag updates from a remote to be forced fetches. Since Git
353 version 2.20, fetching to update refs/tags/* works the same way as
354 when pushing. I.e. any updates will be rejected without + in the
355 refspec (or --force).
356
357 Unlike when pushing with git-push(1), any updates outside of
358 refs/{tags,heads}/* will be accepted without + in the refspec (or
359 --force), whether that’s swapping e.g. a tree object for a blob, or
360 a commit for another commit that’s doesn’t have the previous commit
361 as an ancestor etc.
362
363 Unlike when pushing with git-push(1), there is no configuration
364 which’ll amend these rules, and nothing like a pre-fetch hook
365 analogous to the pre-receive hook.
366
367 As with pushing with git-push(1), all of the rules described above
368 about what’s not allowed as an update can be overridden by adding
369 an the optional leading + to a refspec (or using --force command
370 line option). The only exception to this is that no amount of
371 forcing will make the refs/heads/* namespace accept a non-commit
372 object.
373
374 Note
375 When the remote branch you want to fetch is known to be rewound
376 and rebased regularly, it is expected that its new tip will not
377 be descendant of its previous tip (as stored in your
378 remote-tracking branch the last time you fetched). You would
379 want to use the + sign to indicate non-fast-forward updates
380 will be needed for such branches. There is no way to determine
381 or declare that a branch will be made available in a repository
382 with this behavior; the pulling user simply must know this is
383 the expected usage pattern for a branch.
384
385 --stdin
386 Read refspecs, one per line, from stdin in addition to those
387 provided as arguments. The "tag <name>" format is not supported.
388
390 In general, URLs contain information about the transport protocol, the
391 address of the remote server, and the path to the repository. Depending
392 on the transport protocol, some of this information may be absent.
393
394 Git supports ssh, git, http, and https protocols (in addition, ftp, and
395 ftps can be used for fetching, but this is inefficient and deprecated;
396 do not use it).
397
398 The native transport (i.e. git:// URL) does no authentication and
399 should be used with caution on unsecured networks.
400
401 The following syntaxes may be used with them:
402
403 • ssh://[user@]host.xz[:port]/path/to/repo.git/
404
405 • git://host.xz[:port]/path/to/repo.git/
406
407 • http[s]://host.xz[:port]/path/to/repo.git/
408
409 • ftp[s]://host.xz[:port]/path/to/repo.git/
410
411 An alternative scp-like syntax may also be used with the ssh protocol:
412
413 • [user@]host.xz:path/to/repo.git/
414
415 This syntax is only recognized if there are no slashes before the first
416 colon. This helps differentiate a local path that contains a colon. For
417 example the local path foo:bar could be specified as an absolute path
418 or ./foo:bar to avoid being misinterpreted as an ssh url.
419
420 The ssh and git protocols additionally support ~username expansion:
421
422 • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
423
424 • git://host.xz[:port]/~[user]/path/to/repo.git/
425
426 • [user@]host.xz:/~[user]/path/to/repo.git/
427
428 For local repositories, also supported by Git natively, the following
429 syntaxes may be used:
430
431 • /path/to/repo.git/
432
433 • file:///path/to/repo.git/
434
435 These two syntaxes are mostly equivalent, except when cloning, when the
436 former implies --local option. See git-clone(1) for details.
437
438 git clone, git fetch and git pull, but not git push, will also accept a
439 suitable bundle file. See git-bundle(1).
440
441 When Git doesn’t know how to handle a certain transport protocol, it
442 attempts to use the remote-<transport> remote helper, if one exists. To
443 explicitly request a remote helper, the following syntax may be used:
444
445 • <transport>::<address>
446
447 where <address> may be a path, a server and path, or an arbitrary
448 URL-like string recognized by the specific remote helper being invoked.
449 See gitremote-helpers(7) for details.
450
451 If there are a large number of similarly-named remote repositories and
452 you want to use a different format for them (such that the URLs you use
453 will be rewritten into URLs that work), you can create a configuration
454 section of the form:
455
456 [url "<actual url base>"]
457 insteadOf = <other url base>
458
459 For example, with this:
460
461 [url "git://git.host.xz/"]
462 insteadOf = host.xz:/path/to/
463 insteadOf = work:
464
465 a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
466 rewritten in any context that takes a URL to be
467 "git://git.host.xz/repo.git".
468
469 If you want to rewrite URLs for push only, you can create a
470 configuration section of the form:
471
472 [url "<actual url base>"]
473 pushInsteadOf = <other url base>
474
475 For example, with this:
476
477 [url "ssh://example.org/"]
478 pushInsteadOf = git://example.org/
479
480 a URL like "git://example.org/path/to/repo.git" will be rewritten to
481 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
482 use the original URL.
483
485 The name of one of the following can be used instead of a URL as
486 <repository> argument:
487
488 • a remote in the Git configuration file: $GIT_DIR/config,
489
490 • a file in the $GIT_DIR/remotes directory, or
491
492 • a file in the $GIT_DIR/branches directory.
493
494 All of these also allow you to omit the refspec from the command line
495 because they each contain a refspec which git will use by default.
496
497 Named remote in configuration file
498 You can choose to provide the name of a remote which you had previously
499 configured using git-remote(1), git-config(1) or even by a manual edit
500 to the $GIT_DIR/config file. The URL of this remote will be used to
501 access the repository. The refspec of this remote will be used by
502 default when you do not provide a refspec on the command line. The
503 entry in the config file would appear like this:
504
505 [remote "<name>"]
506 url = <url>
507 pushurl = <pushurl>
508 push = <refspec>
509 fetch = <refspec>
510
511 The <pushurl> is used for pushes only. It is optional and defaults to
512 <url>.
513
514 Named file in $GIT_DIR/remotes
515 You can choose to provide the name of a file in $GIT_DIR/remotes. The
516 URL in this file will be used to access the repository. The refspec in
517 this file will be used as default when you do not provide a refspec on
518 the command line. This file should have the following format:
519
520 URL: one of the above URL format
521 Push: <refspec>
522 Pull: <refspec>
523
524 Push: lines are used by git push and Pull: lines are used by git pull
525 and git fetch. Multiple Push: and Pull: lines may be specified for
526 additional branch mappings.
527
528 Named file in $GIT_DIR/branches
529 You can choose to provide the name of a file in $GIT_DIR/branches. The
530 URL in this file will be used to access the repository. This file
531 should have the following format:
532
533 <url>#<head>
534
535 <url> is required; #<head> is optional.
536
537 Depending on the operation, git will use one of the following refspecs,
538 if you don’t provide one on the command line. <branch> is the name of
539 this file in $GIT_DIR/branches and <head> defaults to master.
540
541 git fetch uses:
542
543 refs/heads/<head>:refs/heads/<branch>
544
545 git push uses:
546
547 HEAD:refs/heads/<head>
548
550 You often interact with the same remote repository by regularly and
551 repeatedly fetching from it. In order to keep track of the progress of
552 such a remote repository, git fetch allows you to configure
553 remote.<repository>.fetch configuration variables.
554
555 Typically such a variable may look like this:
556
557 [remote "origin"]
558 fetch = +refs/heads/*:refs/remotes/origin/*
559
560 This configuration is used in two ways:
561
562 • When git fetch is run without specifying what branches and/or tags
563 to fetch on the command line, e.g. git fetch origin or git fetch,
564 remote.<repository>.fetch values are used as the refspecs—they
565 specify which refs to fetch and which local refs to update. The
566 example above will fetch all branches that exist in the origin
567 (i.e. any ref that matches the left-hand side of the value,
568 refs/heads/*) and update the corresponding remote-tracking branches
569 in the refs/remotes/origin/* hierarchy.
570
571 • When git fetch is run with explicit branches and/or tags to fetch
572 on the command line, e.g. git fetch origin master, the <refspec>s
573 given on the command line determine what are to be fetched (e.g.
574 master in the example, which is a short-hand for master:, which in
575 turn means "fetch the master branch but I do not explicitly say
576 what remote-tracking branch to update with it from the command
577 line"), and the example command will fetch only the master branch.
578 The remote.<repository>.fetch values determine which
579 remote-tracking branch, if any, is updated. When used in this way,
580 the remote.<repository>.fetch values do not have any effect in
581 deciding what gets fetched (i.e. the values are not used as
582 refspecs when the command-line lists refspecs); they are only used
583 to decide where the refs that are fetched are stored by acting as a
584 mapping.
585
586 The latter use of the remote.<repository>.fetch values can be
587 overridden by giving the --refmap=<refspec> parameter(s) on the command
588 line.
589
591 Git has a default disposition of keeping data unless it’s explicitly
592 thrown away; this extends to holding onto local references to branches
593 on remotes that have themselves deleted those branches.
594
595 If left to accumulate, these stale references might make performance
596 worse on big and busy repos that have a lot of branch churn, and e.g.
597 make the output of commands like git branch -a --contains <commit>
598 needlessly verbose, as well as impacting anything else that’ll work
599 with the complete set of known references.
600
601 These remote-tracking references can be deleted as a one-off with
602 either of:
603
604 # While fetching
605 $ git fetch --prune <name>
606
607 # Only prune, don't fetch
608 $ git remote prune <name>
609
610 To prune references as part of your normal workflow without needing to
611 remember to run that, set fetch.prune globally, or remote.<name>.prune
612 per-remote in the config. See git-config(1).
613
614 Here’s where things get tricky and more specific. The pruning feature
615 doesn’t actually care about branches, instead it’ll prune local ←→
616 remote-references as a function of the refspec of the remote (see
617 <refspec> and CONFIGURED REMOTE-TRACKING BRANCHES above).
618
619 Therefore if the refspec for the remote includes e.g.
620 refs/tags/*:refs/tags/*, or you manually run e.g. git fetch --prune
621 <name> "refs/tags/*:refs/tags/*" it won’t be stale remote tracking
622 branches that are deleted, but any local tag that doesn’t exist on the
623 remote.
624
625 This might not be what you expect, i.e. you want to prune remote
626 <name>, but also explicitly fetch tags from it, so when you fetch from
627 it you delete all your local tags, most of which may not have come from
628 the <name> remote in the first place.
629
630 So be careful when using this with a refspec like
631 refs/tags/*:refs/tags/*, or any other refspec which might map
632 references from multiple remotes to the same local namespace.
633
634 Since keeping up-to-date with both branches and tags on the remote is a
635 common use-case the --prune-tags option can be supplied along with
636 --prune to prune local tags that don’t exist on the remote, and
637 force-update those tags that differ. Tag pruning can also be enabled
638 with fetch.pruneTags or remote.<name>.pruneTags in the config. See git-
639 config(1).
640
641 The --prune-tags option is equivalent to having refs/tags/*:refs/tags/*
642 declared in the refspecs of the remote. This can lead to some seemingly
643 strange interactions:
644
645 # These both fetch tags
646 $ git fetch --no-tags origin 'refs/tags/*:refs/tags/*'
647 $ git fetch --no-tags --prune-tags origin
648
649 The reason it doesn’t error out when provided without --prune or its
650 config versions is for flexibility of the configured versions, and to
651 maintain a 1=1 mapping between what the command line flags do, and what
652 the configuration versions do.
653
654 It’s reasonable to e.g. configure fetch.pruneTags=true in ~/.gitconfig
655 to have tags pruned whenever git fetch --prune is run, without making
656 every invocation of git fetch without --prune an error.
657
658 Pruning tags with --prune-tags also works when fetching a URL instead
659 of a named remote. These will all prune tags not found on origin:
660
661 $ git fetch origin --prune --prune-tags
662 $ git fetch origin --prune 'refs/tags/*:refs/tags/*'
663 $ git fetch <url of origin> --prune --prune-tags
664 $ git fetch <url of origin> --prune 'refs/tags/*:refs/tags/*'
665
667 The output of "git fetch" depends on the transport method used; this
668 section describes the output when fetching over the Git protocol
669 (either locally or via ssh) and Smart HTTP protocol.
670
671 The status of the fetch is output in tabular form, with each line
672 representing the status of a single ref. Each line is of the form:
673
674 <flag> <summary> <from> -> <to> [<reason>]
675
676 The status of up-to-date refs is shown only if the --verbose option is
677 used.
678
679 In compact output mode, specified with configuration variable
680 fetch.output, if either entire <from> or <to> is found in the other
681 string, it will be substituted with * in the other string. For example,
682 master -> origin/master becomes master -> origin/*.
683
684 flag
685 A single character indicating the status of the ref:
686
687 (space)
688 for a successfully fetched fast-forward;
689
690 +
691 for a successful forced update;
692
693 -
694 for a successfully pruned ref;
695
696 t
697 for a successful tag update;
698
699 *
700 for a successfully fetched new ref;
701
702 !
703 for a ref that was rejected or failed to update; and
704
705 =
706 for a ref that was up to date and did not need fetching.
707
708 summary
709 For a successfully fetched ref, the summary shows the old and new
710 values of the ref in a form suitable for using as an argument to
711 git log (this is <old>..<new> in most cases, and <old>...<new> for
712 forced non-fast-forward updates).
713
714 from
715 The name of the remote ref being fetched from, minus its
716 refs/<type>/ prefix. In the case of deletion, the name of the
717 remote ref is "(none)".
718
719 to
720 The name of the local ref being updated, minus its refs/<type>/
721 prefix.
722
723 reason
724 A human-readable explanation. In the case of successfully fetched
725 refs, no explanation is needed. For a failed ref, the reason for
726 failure is described.
727
729 • Update the remote-tracking branches:
730
731 $ git fetch origin
732
733 The above command copies all branches from the remote refs/heads/
734 namespace and stores them to the local refs/remotes/origin/
735 namespace, unless the branch.<name>.fetch option is used to specify
736 a non-default refspec.
737
738 • Using refspecs explicitly:
739
740 $ git fetch origin +seen:seen maint:tmp
741
742 This updates (or creates, as necessary) branches seen and tmp in
743 the local repository by fetching from the branches (respectively)
744 seen and maint from the remote repository.
745
746 The seen branch will be updated even if it does not fast-forward,
747 because it is prefixed with a plus sign; tmp will not be.
748
749 • Peek at a remote’s branch, without configuring the remote in your
750 local repository:
751
752 $ git fetch git://git.kernel.org/pub/scm/git/git.git maint
753 $ git log FETCH_HEAD
754
755 The first command fetches the maint branch from the repository at
756 git://git.kernel.org/pub/scm/git/git.git and the second command
757 uses FETCH_HEAD to examine the branch with git-log(1). The fetched
758 objects will eventually be removed by git’s built-in housekeeping
759 (see git-gc(1)).
760
762 The fetch and push protocols are not designed to prevent one side from
763 stealing data from the other repository that was not intended to be
764 shared. If you have private data that you need to protect from a
765 malicious peer, your best option is to store it in another repository.
766 This applies to both clients and servers. In particular, namespaces on
767 a server are not effective for read access control; you should only
768 grant read access to a namespace to clients that you would trust with
769 read access to the entire repository.
770
771 The known attack vectors are as follows:
772
773 1. The victim sends "have" lines advertising the IDs of objects it has
774 that are not explicitly intended to be shared but can be used to
775 optimize the transfer if the peer also has them. The attacker
776 chooses an object ID X to steal and sends a ref to X, but isn’t
777 required to send the content of X because the victim already has
778 it. Now the victim believes that the attacker has X, and it sends
779 the content of X back to the attacker later. (This attack is most
780 straightforward for a client to perform on a server, by creating a
781 ref to X in the namespace the client has access to and then
782 fetching it. The most likely way for a server to perform it on a
783 client is to "merge" X into a public branch and hope that the user
784 does additional work on this branch and pushes it back to the
785 server without noticing the merge.)
786
787 2. As in #1, the attacker chooses an object ID X to steal. The victim
788 sends an object Y that the attacker already has, and the attacker
789 falsely claims to have X and not Y, so the victim sends Y as a
790 delta against X. The delta reveals regions of X that are similar to
791 Y to the attacker.
792
794 Using --recurse-submodules can only fetch new commits in already
795 checked out submodules right now. When e.g. upstream added a new
796 submodule in the just fetched commits of the superproject the submodule
797 itself cannot be fetched, making it impossible to check out that
798 submodule later without having to do a fetch again. This is expected to
799 be fixed in a future Git version.
800
802 git-pull(1)
803
805 Part of the git(1) suite
806
807
808
809Git 2.33.1 2021-10-12 GIT-FETCH(1)