logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-fetch.1 (48615B)


  1. '\" t
  2. .\" Title: git-fetch
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-FETCH" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-fetch \- Download objects and refs from another repository
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit fetch\fR [<options>] [<repository> [<refspec>\&...\:]]
  36. \fIgit fetch\fR [<options>] <group>
  37. \fIgit fetch\fR \-\-multiple [<options>] [(<repository> | <group>)\&...\:]
  38. \fIgit fetch\fR \-\-all [<options>]
  39. .fi
  40. .SH "DESCRIPTION"
  41. .sp
  42. 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 <refspec> below for ways to control this behavior)\&.
  43. .sp
  44. By default, any tag that points into the histories being fetched is also fetched; the effect is to fetch tags that point at branches that you are interested in\&. This default behavior can be changed by using the \-\-tags or \-\-no\-tags options or by configuring remote\&.<name>\&.tagOpt\&. By using a refspec that fetches tags explicitly, you can fetch tags that do not point into branches you are interested in as well\&.
  45. .sp
  46. \fIgit fetch\fR can fetch from either a single named repository or URL, or from several repositories at once if <group> is given and there is a remotes\&.<group> entry in the configuration file\&. (See \fBgit-config\fR(1))\&.
  47. .sp
  48. 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\&.
  49. .sp
  50. The names of refs that are fetched, together with the object names they point at, are written to \&.\fBgit/FETCH_HEAD\fR\&. This information may be used by scripts or other git commands, such as \fBgit-pull\fR(1)\&.
  51. .SH "OPTIONS"
  52. .PP
  53. \-\-[no\-]all
  54. .RS 4
  55. Fetch all remotes, except for the ones that has the
  56. \fBremote\&.\fR\fI<name>\fR\fB\&.skipFetchAll\fR
  57. configuration variable set\&. This overrides the configuration variable fetch\&.all`\&.
  58. .RE
  59. .PP
  60. \-a, \-\-append
  61. .RS 4
  62. Append ref names and object names of fetched refs to the existing contents of \&.\fBgit/FETCH_HEAD\fR\&. Without this option old data in \&.\fBgit/FETCH_HEAD\fR
  63. will be overwritten\&.
  64. .RE
  65. .PP
  66. \-\-atomic
  67. .RS 4
  68. Use an atomic transaction to update local refs\&. Either all refs are updated, or on error, no refs are updated\&.
  69. .RE
  70. .PP
  71. \-\-depth=<depth>
  72. .RS 4
  73. Limit fetching to the specified number of commits from the tip of each remote branch history\&. If fetching to a
  74. \fIshallow\fR
  75. repository created by
  76. \fBgit\fR
  77. \fBclone\fR
  78. with
  79. \fB\-\-depth=\fR\fI<depth>\fR
  80. option (see
  81. \fBgit-clone\fR(1)), deepen or shorten the history to the specified number of commits\&. Tags for the deepened commits are not fetched\&.
  82. .RE
  83. .PP
  84. \-\-deepen=<depth>
  85. .RS 4
  86. Similar to \-\-depth, except it specifies the number of commits from the current shallow boundary instead of from the tip of each remote branch history\&.
  87. .RE
  88. .PP
  89. \-\-shallow\-since=<date>
  90. .RS 4
  91. Deepen or shorten the history of a shallow repository to include all reachable commits after <date>\&.
  92. .RE
  93. .PP
  94. \-\-shallow\-exclude=<ref>
  95. .RS 4
  96. 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\&.
  97. .RE
  98. .PP
  99. \-\-unshallow
  100. .RS 4
  101. If the source repository is complete, convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories\&.
  102. .sp
  103. If the source repository is shallow, fetch as much as possible so that the current repository has the same history as the source repository\&.
  104. .RE
  105. .PP
  106. \-\-update\-shallow
  107. .RS 4
  108. By default when fetching from a shallow repository,
  109. \fBgit\fR
  110. \fBfetch\fR
  111. refuses refs that require updating \&.git/shallow\&. This option updates \&.git/shallow and accepts such refs\&.
  112. .RE
  113. .PP
  114. \-\-negotiation\-tip=<commit|glob>
  115. .RS 4
  116. 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\&.
  117. .sp
  118. This option may be specified more than once; if so, Git will report commits reachable from any of the given commits\&.
  119. .sp
  120. 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\&.
  121. .sp
  122. See also the
  123. \fBfetch\&.negotiationAlgorithm\fR
  124. and
  125. \fBpush\&.negotiate\fR
  126. configuration variables documented in
  127. \fBgit-config\fR(1), and the
  128. \fB\-\-negotiate\-only\fR
  129. option below\&.
  130. .RE
  131. .PP
  132. \-\-negotiate\-only
  133. .RS 4
  134. Do not fetch anything from the server, and instead print the ancestors of the provided
  135. \fB\-\-negotiation\-tip=\fR* arguments, which we have in common with the server\&.
  136. .sp
  137. This is incompatible with
  138. \fB\-\-recurse\-submodules=\fR[\fByes\fR|\fBon\-demand\fR]\&. Internally this is used to implement the
  139. \fBpush\&.negotiate\fR
  140. option, see
  141. \fBgit-config\fR(1)\&.
  142. .RE
  143. .PP
  144. \-\-dry\-run
  145. .RS 4
  146. Show what would be done, without making any changes\&.
  147. .RE
  148. .PP
  149. \-\-porcelain
  150. .RS 4
  151. Print the output to standard output in an easy\-to\-parse format for scripts\&. See section OUTPUT in
  152. \fBgit-fetch\fR(1)
  153. for details\&.
  154. .sp
  155. This is incompatible with
  156. \fB\-\-recurse\-submodules=\fR[\fByes\fR|\fBon\-demand\fR] and takes precedence over the
  157. \fBfetch\&.output\fR
  158. config option\&.
  159. .RE
  160. .PP
  161. \-\-[no\-]write\-fetch\-head
  162. .RS 4
  163. Write the list of remote refs fetched in the
  164. \fBFETCH_HEAD\fR
  165. file directly under
  166. \fB$GIT_DIR\fR\&. This is the default\&. Passing
  167. \fB\-\-no\-write\-fetch\-head\fR
  168. from the command line tells Git not to write the file\&. Under
  169. \fB\-\-dry\-run\fR
  170. option, the file is never written\&.
  171. .RE
  172. .PP
  173. \-f, \-\-force
  174. .RS 4
  175. When
  176. \fIgit fetch\fR
  177. is used with
  178. \fI<src>\fR\fB:\fR\fI<dst>\fR
  179. refspec, it may refuse to update the local branch as discussed in the
  180. \fI<refspec>\fR
  181. part below\&. This option overrides that check\&.
  182. .RE
  183. .PP
  184. \-k, \-\-keep
  185. .RS 4
  186. Keep downloaded pack\&.
  187. .RE
  188. .PP
  189. \-\-multiple
  190. .RS 4
  191. Allow several <repository> and <group> arguments to be specified\&. No <refspec>s may be specified\&.
  192. .RE
  193. .PP
  194. \-\-[no\-]auto\-maintenance, \-\-[no\-]auto\-gc
  195. .RS 4
  196. Run
  197. \fBgit\fR
  198. \fBmaintenance\fR
  199. \fBrun\fR
  200. \fB\-\-auto\fR
  201. at the end to perform automatic repository maintenance if needed\&. (\fB\-\-\fR[\fBno\-\fR]\fBauto\-gc\fR
  202. is a synonym\&.) This is enabled by default\&.
  203. .RE
  204. .PP
  205. \-\-[no\-]write\-commit\-graph
  206. .RS 4
  207. Write a commit\-graph after fetching\&. This overrides the config setting
  208. \fBfetch\&.writeCommitGraph\fR\&.
  209. .RE
  210. .PP
  211. \-\-prefetch
  212. .RS 4
  213. Modify the configured refspec to place all refs into the
  214. \fBrefs/prefetch/\fR
  215. namespace\&. See the
  216. \fBprefetch\fR
  217. task in
  218. \fBgit-maintenance\fR(1)\&.
  219. .RE
  220. .PP
  221. \-p, \-\-prune
  222. .RS 4
  223. Before fetching, remove any remote\-tracking references that no longer exist on the remote\&. Tags are not subject to pruning if they are fetched only because of the default tag auto\-following or due to a \-\-tags option\&. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the \-\-mirror option), then they are also subject to pruning\&. Supplying
  224. \fB\-\-prune\-tags\fR
  225. is a shorthand for providing the tag refspec\&.
  226. .sp
  227. See the PRUNING section below for more details\&.
  228. .RE
  229. .PP
  230. \-P, \-\-prune\-tags
  231. .RS 4
  232. Before fetching, remove any local tags that no longer exist on the remote if
  233. \fB\-\-prune\fR
  234. is enabled\&. This option should be used more carefully, unlike
  235. \fB\-\-prune\fR
  236. 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
  237. \fB\-\-prune\fR, see the discussion about that in its documentation\&.
  238. .sp
  239. See the PRUNING section below for more details\&.
  240. .RE
  241. .PP
  242. \-n, \-\-no\-tags
  243. .RS 4
  244. By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally\&. This option disables this automatic tag following\&. The default behavior for a remote may be specified with the remote\&.<name>\&.tagOpt setting\&. See
  245. \fBgit-config\fR(1)\&.
  246. .RE
  247. .PP
  248. \-\-refetch
  249. .RS 4
  250. 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
  251. \fB\-\-filter=\fR
  252. when the filter definition has changed\&. Automatic post\-fetch maintenance will perform object database pack consolidation to remove any duplicate objects\&.
  253. .RE
  254. .PP
  255. \-\-refmap=<refspec>
  256. .RS 4
  257. 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
  258. \fBremote\&.\fR*\&.\fBfetch\fR
  259. configuration variables for the remote repository\&. Providing an empty
  260. \fI<refspec>\fR
  261. to the
  262. \fB\-\-refmap\fR
  263. 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\&.
  264. .RE
  265. .PP
  266. \-t, \-\-tags
  267. .RS 4
  268. Fetch all tags from the remote (i\&.e\&., fetch remote tags
  269. \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 \-\-prune is used (though tags may be pruned anyway if they are also the destination of an explicit refspec; see
  270. \fB\-\-prune\fR)\&.
  271. .RE
  272. .PP
  273. \-\-recurse\-submodules[=(yes|on\-demand|no)]
  274. .RS 4
  275. This option controls if and under what conditions new commits of submodules should be fetched too\&. When recursing through submodules,
  276. \fBgit\fR
  277. \fBfetch\fR
  278. 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
  279. \fB$GIT_DIR/modules/\fR
  280. (see
  281. \fBgitsubmodules\fR(7)); if the upstream adds a new submodule, that submodule cannot be fetched until it is cloned e\&.g\&. by
  282. \fBgit\fR
  283. \fBsubmodule\fR
  284. \fBupdate\fR\&.
  285. .sp
  286. When set to
  287. \fIon\-demand\fR, only changed submodules are fetched\&. When set to
  288. \fIyes\fR, all populated submodules are fetched and submodules that are both unpopulated and changed are fetched\&. When set to
  289. \fIno\fR, submodules are never fetched\&.
  290. .sp
  291. When unspecified, this uses the value of
  292. \fBfetch\&.recurseSubmodules\fR
  293. if it is set (see
  294. \fBgit-config\fR(1)), defaulting to
  295. \fIon\-demand\fR
  296. if unset\&. When this option is used without any value, it defaults to
  297. \fIyes\fR\&.
  298. .RE
  299. .PP
  300. \-j, \-\-jobs=<n>
  301. .RS 4
  302. Number of parallel children to be used for all forms of fetching\&.
  303. .sp
  304. If the
  305. \fB\-\-multiple\fR
  306. 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
  307. \fBfetch\&.parallel\fR
  308. and
  309. \fBsubmodule\&.fetchJobs\fR
  310. (see
  311. \fBgit-config\fR(1))\&.
  312. .sp
  313. Typically, parallel recursive and multi\-remote fetches will be faster\&. By default fetches are performed sequentially, not in parallel\&.
  314. .RE
  315. .PP
  316. \-\-no\-recurse\-submodules
  317. .RS 4
  318. Disable recursive fetching of submodules (this has the same effect as using the
  319. \fB\-\-recurse\-submodules=no\fR
  320. option)\&.
  321. .RE
  322. .PP
  323. \-\-set\-upstream
  324. .RS 4
  325. If the remote is fetched successfully, add upstream (tracking) reference, used by argument\-less
  326. \fBgit-pull\fR(1)
  327. and other commands\&. For more information, see
  328. \fBbranch\&.\fR\fI<name>\fR\fB\&.merge\fR
  329. and
  330. \fBbranch\&.\fR\fI<name>\fR\fB\&.remote\fR
  331. in
  332. \fBgit-config\fR(1)\&.
  333. .RE
  334. .PP
  335. \-\-submodule\-prefix=<path>
  336. .RS 4
  337. Prepend <path> to paths printed in informative messages such as "Fetching submodule foo"\&. This option is used internally when recursing over submodules\&.
  338. .RE
  339. .PP
  340. \-\-recurse\-submodules\-default=[yes|on\-demand]
  341. .RS 4
  342. This option is used internally to temporarily provide a non\-negative default value for the \-\-recurse\-submodules option\&. All other methods of configuring fetch\(cqs submodule recursion (such as settings in
  343. \fBgitmodules\fR(5)
  344. and
  345. \fBgit-config\fR(1)) override this option, as does specifying \-\-[no\-]recurse\-submodules directly\&.
  346. .RE
  347. .PP
  348. \-u, \-\-update\-head\-ok
  349. .RS 4
  350. By default
  351. \fIgit fetch\fR
  352. refuses to update the head which corresponds to the current branch\&. This flag disables the check\&. This is purely for the internal use for
  353. \fIgit pull\fR
  354. to communicate with
  355. \fIgit fetch\fR, and unless you are implementing your own Porcelain you are not supposed to use it\&.
  356. .RE
  357. .PP
  358. \-\-upload\-pack <upload\-pack>
  359. .RS 4
  360. When given, and the repository to fetch from is handled by
  361. \fIgit fetch\-pack\fR,
  362. \fB\-\-exec=\fR\fI<upload\-pack>\fR
  363. is passed to the command to specify non\-default path for the command run on the other end\&.
  364. .RE
  365. .PP
  366. \-q, \-\-quiet
  367. .RS 4
  368. Pass \-\-quiet to git\-fetch\-pack and silence any other internally used git commands\&. Progress is not reported to the standard error stream\&.
  369. .RE
  370. .PP
  371. \-v, \-\-verbose
  372. .RS 4
  373. Be verbose\&.
  374. .RE
  375. .PP
  376. \-\-progress
  377. .RS 4
  378. Progress status is reported on the standard error stream by default when it is attached to a terminal, unless \-q is specified\&. This flag forces progress status even if the standard error stream is not directed to a terminal\&.
  379. .RE
  380. .PP
  381. \-o <option>, \-\-server\-option=<option>
  382. .RS 4
  383. Transmit the given string to the server when communicating using protocol version 2\&. The given string must not contain a NUL or LF character\&. The server\(cqs handling of server options, including unknown ones, is server\-specific\&. When multiple
  384. \fB\-\-server\-option=\fR\fI<option>\fR
  385. are given, they are all sent to the other side in the order listed on the command line\&. When no
  386. \fB\-\-server\-option=\fR\fI<option>\fR
  387. is given from the command line, the values of configuration variable
  388. \fBremote\&.\fR\fI<name>\fR\fB\&.serverOption\fR
  389. are used instead\&.
  390. .RE
  391. .PP
  392. \-\-show\-forced\-updates
  393. .RS 4
  394. By default, git checks if a branch is force\-updated during fetch\&. This can be disabled through fetch\&.showForcedUpdates, but the \-\-show\-forced\-updates option guarantees this check occurs\&. See
  395. \fBgit-config\fR(1)\&.
  396. .RE
  397. .PP
  398. \-\-no\-show\-forced\-updates
  399. .RS 4
  400. By default, git checks if a branch is force\-updated during fetch\&. Pass \-\-no\-show\-forced\-updates or set fetch\&.showForcedUpdates to false to skip this check for performance reasons\&. If used during
  401. \fIgit\-pull\fR
  402. the \-\-ff\-only option will still check for forced updates before attempting a fast\-forward update\&. See
  403. \fBgit-config\fR(1)\&.
  404. .RE
  405. .PP
  406. \-4, \-\-ipv4
  407. .RS 4
  408. Use IPv4 addresses only, ignoring IPv6 addresses\&.
  409. .RE
  410. .PP
  411. \-6, \-\-ipv6
  412. .RS 4
  413. Use IPv6 addresses only, ignoring IPv4 addresses\&.
  414. .RE
  415. .PP
  416. <repository>
  417. .RS 4
  418. The "remote" repository that is the source of a fetch or pull operation\&. This parameter can be either a URL (see the section
  419. GIT URLS
  420. below) or the name of a remote (see the section
  421. REMOTES
  422. below)\&.
  423. .RE
  424. .PP
  425. <group>
  426. .RS 4
  427. A name referring to a list of repositories as the value of remotes\&.<group> in the configuration file\&. (See
  428. \fBgit-config\fR(1))\&.
  429. .RE
  430. .PP
  431. <refspec>
  432. .RS 4
  433. Specifies which refs to fetch and which local refs to update\&. When no <refspec>s appear on the command line, the refs to fetch are read from
  434. \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR
  435. variables instead (see
  436. CONFIGURED REMOTE\-TRACKING BRANCHES
  437. below)\&.
  438. .sp
  439. The format of a <refspec> parameter is an optional plus
  440. \fB+\fR, followed by the source <src>, followed by a colon
  441. \fB:\fR, followed by the destination <dst>\&. The colon can be omitted when <dst> is empty\&. <src> is typically a ref, or a glob pattern with a single * that is used to match a set of refs, but it can also be a fully spelled hex object name\&.
  442. .sp
  443. A <refspec> may contain a * in its <src> to indicate a simple pattern match\&. Such a refspec functions like a glob that matches any ref with the pattern\&. A pattern <refspec> must have one and only one * in both the <src> and <dst>\&. It will map refs to the destination by replacing the * with the contents matched from the source\&.
  444. .sp
  445. If a refspec is prefixed by
  446. \fB^\fR, it will be interpreted as a negative refspec\&. Rather than specifying which refs to fetch or which local refs to update, such a refspec will instead specify refs to exclude\&. A ref will be considered to match if it matches at least one positive refspec, and does not match any negative refspec\&. Negative refspecs can be useful to restrict the scope of a pattern refspec so that it will not include specific refs\&. Negative refspecs can themselves be pattern refspecs\&. However, they may only contain a <src> and do not specify a <dst>\&. Fully spelled out hex object names are also not supported\&.
  447. .sp
  448. \fBtag\fR
  449. \fI<tag>\fR
  450. means the same as
  451. \fBrefs/tags/\fR\fI<tag>\fR\fB:refs/tags/\fR\fI<tag>\fR; it requests fetching everything up to the given tag\&.
  452. .sp
  453. The remote ref that matches <src> is fetched, and if <dst> is not an empty string, an attempt is made to update the local ref that matches it\&.
  454. .sp
  455. Whether that update is allowed without
  456. \fB\-\-force\fR
  457. depends on the ref namespace it\(cqs being fetched to, the type of object being fetched, and whether the update is considered to be a fast\-forward\&. Generally, the same rules apply for fetching as when pushing, see the
  458. \fI<refspec>\fR\&.\&.\&. section of
  459. \fBgit-push\fR(1)
  460. for what those are\&. Exceptions to those rules particular to
  461. \fIgit fetch\fR
  462. are noted below\&.
  463. .sp
  464. Until Git version 2\&.20, and unlike when pushing with
  465. \fBgit-push\fR(1), any updates to
  466. \fBrefs/tags/\fR* would be accepted without
  467. \fB+\fR
  468. in the refspec (or
  469. \fB\-\-force\fR)\&. When fetching, we promiscuously considered all tag updates from a remote to be forced fetches\&. Since Git version 2\&.20, fetching to update
  470. \fBrefs/tags/\fR* works the same way as when pushing\&. I\&.e\&. any updates will be rejected without
  471. \fB+\fR
  472. in the refspec (or
  473. \fB\-\-force\fR)\&.
  474. .sp
  475. Unlike when pushing with
  476. \fBgit-push\fR(1), any updates outside of
  477. \fBrefs/\fR{tags,heads}/* will be accepted without
  478. \fB+\fR
  479. in the refspec (or
  480. \fB\-\-force\fR), whether that\(cqs swapping e\&.g\&. a tree object for a blob, or a commit for another commit that doesn\(cqt have the previous commit as an ancestor etc\&.
  481. .sp
  482. Unlike when pushing with
  483. \fBgit-push\fR(1), there is no configuration which\(cqll amend these rules, and nothing like a
  484. \fBpre\-fetch\fR
  485. hook analogous to the
  486. \fBpre\-receive\fR
  487. hook\&.
  488. .sp
  489. As with pushing with
  490. \fBgit-push\fR(1), all of the rules described above about what\(cqs not allowed as an update can be overridden by adding an optional leading
  491. \fB+\fR
  492. to a refspec (or using the
  493. \fB\-\-force\fR
  494. command line option)\&. The only exception to this is that no amount of forcing will make the
  495. \fBrefs/heads/\fR* namespace accept a non\-commit object\&.
  496. .if n \{\
  497. .sp
  498. .\}
  499. .RS 4
  500. .it 1 an-trap
  501. .nr an-no-space-flag 1
  502. .nr an-break-flag 1
  503. .br
  504. .ps +1
  505. \fBNote\fR
  506. .ps -1
  507. .br
  508. When the remote branch you want to fetch is known to be rewound and rebased regularly, it is expected that its new tip will not be a descendant of its previous tip (as stored in your remote\-tracking branch the last time you fetched)\&. You would want to use the
  509. \fB+\fR
  510. sign to indicate non\-fast\-forward updates will be needed for such branches\&. There is no way to determine or declare that a branch will be made available in a repository with this behavior; the pulling user simply must know this is the expected usage pattern for a branch\&.
  511. .sp .5v
  512. .RE
  513. .RE
  514. .PP
  515. \-\-stdin
  516. .RS 4
  517. Read refspecs, one per line, from stdin in addition to those provided as arguments\&. The "tag <name>" format is not supported\&.
  518. .RE
  519. .SH "GIT URLS"
  520. .sp
  521. In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository\&. Depending on the transport protocol, some of this information may be absent\&.
  522. .sp
  523. Git supports ssh, git, http, and https protocols (in addition, ftp and ftps can be used for fetching, but this is inefficient and deprecated; do not use them)\&.
  524. .sp
  525. The native transport (i\&.e\&. \fBgit://\fR URL) does no authentication and should be used with caution on unsecured networks\&.
  526. .sp
  527. The following syntaxes may be used with them:
  528. .sp
  529. .RS 4
  530. .ie n \{\
  531. \h'-04'\(bu\h'+03'\c
  532. .\}
  533. .el \{\
  534. .sp -1
  535. .IP \(bu 2.3
  536. .\}
  537. \fBssh://\fR[\fI<user>\fR\fB@\fR]\fI<host>\fR[\fB:\fR\fI<port>\fR]\fB/\fR\fI<path\-to\-git\-repo>\fR
  538. .RE
  539. .sp
  540. .RS 4
  541. .ie n \{\
  542. \h'-04'\(bu\h'+03'\c
  543. .\}
  544. .el \{\
  545. .sp -1
  546. .IP \(bu 2.3
  547. .\}
  548. \fBgit://\fR\fI<host>\fR[\fB:\fR\fI<port>\fR]\fB/\fR\fI<path\-to\-git\-repo>\fR
  549. .RE
  550. .sp
  551. .RS 4
  552. .ie n \{\
  553. \h'-04'\(bu\h'+03'\c
  554. .\}
  555. .el \{\
  556. .sp -1
  557. .IP \(bu 2.3
  558. .\}
  559. \fBhttp\fR[\fBs\fR]\fB://\fR\fI<host>\fR[\fB:\fR\fI<port>\fR]\fB/\fR\fI<path\-to\-git\-repo>\fR
  560. .RE
  561. .sp
  562. .RS 4
  563. .ie n \{\
  564. \h'-04'\(bu\h'+03'\c
  565. .\}
  566. .el \{\
  567. .sp -1
  568. .IP \(bu 2.3
  569. .\}
  570. \fBftp\fR[\fBs\fR]\fB://\fR\fI<host>\fR[\fB:\fR\fI<port>\fR]\fB/\fR\fI<path\-to\-git\-repo>\fR
  571. .RE
  572. .sp
  573. An alternative scp\-like syntax may also be used with the ssh protocol:
  574. .sp
  575. .RS 4
  576. .ie n \{\
  577. \h'-04'\(bu\h'+03'\c
  578. .\}
  579. .el \{\
  580. .sp -1
  581. .IP \(bu 2.3
  582. .\}
  583. [\fI<user>\fR\fB@\fR]\fI<host>\fR\fB:/\fR\fI<path\-to\-git\-repo>\fR
  584. .RE
  585. .sp
  586. This syntax is only recognized if there are no slashes before the first colon\&. This helps differentiate a local path that contains a colon\&. For example the local path \fBfoo:bar\fR could be specified as an absolute path or \&.\fB/foo:bar\fR to avoid being misinterpreted as an ssh url\&.
  587. .sp
  588. The ssh and git protocols additionally support \fB~\fR\fI<username>\fR expansion:
  589. .sp
  590. .RS 4
  591. .ie n \{\
  592. \h'-04'\(bu\h'+03'\c
  593. .\}
  594. .el \{\
  595. .sp -1
  596. .IP \(bu 2.3
  597. .\}
  598. \fBssh://\fR[\fI<user>\fR\fB@\fR]\fI<host>\fR[\fB:\fR\fI<port>\fR]\fB/~\fR\fI<user>\fR\fB/\fR\fI<path\-to\-git\-repo>\fR
  599. .RE
  600. .sp
  601. .RS 4
  602. .ie n \{\
  603. \h'-04'\(bu\h'+03'\c
  604. .\}
  605. .el \{\
  606. .sp -1
  607. .IP \(bu 2.3
  608. .\}
  609. \fBgit://\fR\fI<host>\fR[\fB:\fR\fI<port>\fR]\fB/~\fR\fI<user>\fR\fB/\fR\fI<path\-to\-git\-repo>\fR
  610. .RE
  611. .sp
  612. .RS 4
  613. .ie n \{\
  614. \h'-04'\(bu\h'+03'\c
  615. .\}
  616. .el \{\
  617. .sp -1
  618. .IP \(bu 2.3
  619. .\}
  620. [\fI<user>\fR\fB@\fR]\fI<host>\fR\fB:~\fR\fI<user>\fR\fB/\fR\fI<path\-to\-git\-repo>\fR
  621. .RE
  622. .sp
  623. For local repositories, also supported by Git natively, the following syntaxes may be used:
  624. .sp
  625. .RS 4
  626. .ie n \{\
  627. \h'-04'\(bu\h'+03'\c
  628. .\}
  629. .el \{\
  630. .sp -1
  631. .IP \(bu 2.3
  632. .\}
  633. \fB/path/to/repo\&.git/\fR
  634. .RE
  635. .sp
  636. .RS 4
  637. .ie n \{\
  638. \h'-04'\(bu\h'+03'\c
  639. .\}
  640. .el \{\
  641. .sp -1
  642. .IP \(bu 2.3
  643. .\}
  644. \fBfile:///path/to/repo\&.git/\fR
  645. .RE
  646. .sp
  647. These two syntaxes are mostly equivalent, except when cloning, when the former implies \fB\-\-local\fR option\&. See \fBgit-clone\fR(1) for details\&.
  648. .sp
  649. \fBgit\fR \fBclone\fR, \fBgit\fR \fBfetch\fR and \fBgit\fR \fBpull\fR, but not \fBgit\fR \fBpush\fR, will also accept a suitable bundle file\&. See \fBgit-bundle\fR(1)\&.
  650. .sp
  651. When Git doesn\(cqt know how to handle a certain transport protocol, it attempts to use the \fBremote\-\fR\fI<transport>\fR remote helper, if one exists\&. To explicitly request a remote helper, the following syntax may be used:
  652. .sp
  653. .RS 4
  654. .ie n \{\
  655. \h'-04'\(bu\h'+03'\c
  656. .\}
  657. .el \{\
  658. .sp -1
  659. .IP \(bu 2.3
  660. .\}
  661. \fI<transport>\fR\fB::\fR\fI<address>\fR
  662. .RE
  663. .sp
  664. where \fI<address>\fR may be a path, a server and path, or an arbitrary URL\-like string recognized by the specific remote helper being invoked\&. See \fBgitremote-helpers\fR(7) for details\&.
  665. .sp
  666. If there are a large number of similarly\-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:
  667. .sp
  668. .if n \{\
  669. .RS 4
  670. .\}
  671. .nf
  672. [url "\fI<actual\-url\-base>\fR"]
  673. insteadOf = \fI<other\-url\-base>\fR
  674. .fi
  675. .if n \{\
  676. .RE
  677. .\}
  678. .sp
  679. For example, with this:
  680. .sp
  681. .if n \{\
  682. .RS 4
  683. .\}
  684. .nf
  685. [url "git://git\&.host\&.xz/"]
  686. insteadOf = host\&.xz:/path/to/
  687. insteadOf = work:
  688. .fi
  689. .if n \{\
  690. .RE
  691. .\}
  692. .sp
  693. a URL like "work:repo\&.git" or like "host\&.xz:/path/to/repo\&.git" will be rewritten in any context that takes a URL to be "git://git\&.host\&.xz/repo\&.git"\&.
  694. .sp
  695. If you want to rewrite URLs for push only, you can create a configuration section of the form:
  696. .sp
  697. .if n \{\
  698. .RS 4
  699. .\}
  700. .nf
  701. [url "\fI<actual\-url\-base>\fR"]
  702. pushInsteadOf = \fI<other\-url\-base>\fR
  703. .fi
  704. .if n \{\
  705. .RE
  706. .\}
  707. .sp
  708. For example, with this:
  709. .sp
  710. .if n \{\
  711. .RS 4
  712. .\}
  713. .nf
  714. [url "ssh://example\&.org/"]
  715. pushInsteadOf = git://example\&.org/
  716. .fi
  717. .if n \{\
  718. .RE
  719. .\}
  720. .sp
  721. a URL like "git://example\&.org/path/to/repo\&.git" will be rewritten to "ssh://example\&.org/path/to/repo\&.git" for pushes, but pulls will still use the original URL\&.
  722. .SH "REMOTES"
  723. .sp
  724. The name of one of the following can be used instead of a URL as \fI<repository>\fR argument:
  725. .sp
  726. .RS 4
  727. .ie n \{\
  728. \h'-04'\(bu\h'+03'\c
  729. .\}
  730. .el \{\
  731. .sp -1
  732. .IP \(bu 2.3
  733. .\}
  734. a remote in the Git configuration file:
  735. \fB$GIT_DIR/config\fR,
  736. .RE
  737. .sp
  738. .RS 4
  739. .ie n \{\
  740. \h'-04'\(bu\h'+03'\c
  741. .\}
  742. .el \{\
  743. .sp -1
  744. .IP \(bu 2.3
  745. .\}
  746. a file in the
  747. \fB$GIT_DIR/remotes\fR
  748. directory, or
  749. .RE
  750. .sp
  751. .RS 4
  752. .ie n \{\
  753. \h'-04'\(bu\h'+03'\c
  754. .\}
  755. .el \{\
  756. .sp -1
  757. .IP \(bu 2.3
  758. .\}
  759. a file in the
  760. \fB$GIT_DIR/branches\fR
  761. directory\&.
  762. .RE
  763. .sp
  764. All of these also allow you to omit the refspec from the command line because they each contain a refspec which git will use by default\&.
  765. .SS "Named remote in configuration file"
  766. .sp
  767. You can choose to provide the name of a remote which you had previously configured using \fBgit-remote\fR(1), \fBgit-config\fR(1) or even by a manual edit to the \fB$GIT_DIR/config\fR file\&. The URL of this remote will be used to access the repository\&. The refspec of this remote will be used by default when you do not provide a refspec on the command line\&. The entry in the config file would appear like this:
  768. .sp
  769. .if n \{\
  770. .RS 4
  771. .\}
  772. .nf
  773. [remote "<name>"]
  774. url = <URL>
  775. pushurl = <pushurl>
  776. push = <refspec>
  777. fetch = <refspec>
  778. .fi
  779. .if n \{\
  780. .RE
  781. .\}
  782. .sp
  783. The \fI<pushurl>\fR is used for pushes only\&. It is optional and defaults to \fI<URL>\fR\&. Pushing to a remote affects all defined pushurls or all defined urls if no pushurls are defined\&. Fetch, however, will only fetch from the first defined url if multiple urls are defined\&.
  784. .SS "Named file in \fB$GIT_DIR/remotes\fR"
  785. .sp
  786. You can choose to provide the name of a file in \fB$GIT_DIR/remotes\fR\&. The URL in this file will be used to access the repository\&. The refspec in this file will be used as default when you do not provide a refspec on the command line\&. This file should have the following format:
  787. .sp
  788. .if n \{\
  789. .RS 4
  790. .\}
  791. .nf
  792. URL: one of the above URL formats
  793. Push: <refspec>
  794. Pull: <refspec>
  795. .fi
  796. .if n \{\
  797. .RE
  798. .\}
  799. .sp
  800. \fBPush:\fR lines are used by \fIgit push\fR and \fBPull:\fR lines are used by \fIgit pull\fR and \fIgit fetch\fR\&. Multiple \fBPush:\fR and \fBPull:\fR lines may be specified for additional branch mappings\&.
  801. .SS "Named file in \fB$GIT_DIR/branches\fR"
  802. .sp
  803. You can choose to provide the name of a file in \fB$GIT_DIR/branches\fR\&. The URL in this file will be used to access the repository\&. This file should have the following format:
  804. .sp
  805. .if n \{\
  806. .RS 4
  807. .\}
  808. .nf
  809. <URL>#<head>
  810. .fi
  811. .if n \{\
  812. .RE
  813. .\}
  814. .sp
  815. \fI<URL>\fR is required; #\fI<head>\fR is optional\&.
  816. .sp
  817. Depending on the operation, git will use one of the following refspecs, if you don\(cqt provide one on the command line\&. \fI<branch>\fR is the name of this file in \fB$GIT_DIR/branches\fR and \fI<head>\fR defaults to \fBmaster\fR\&.
  818. .sp
  819. git fetch uses:
  820. .sp
  821. .if n \{\
  822. .RS 4
  823. .\}
  824. .nf
  825. refs/heads/<head>:refs/heads/<branch>
  826. .fi
  827. .if n \{\
  828. .RE
  829. .\}
  830. .sp
  831. git push uses:
  832. .sp
  833. .if n \{\
  834. .RS 4
  835. .\}
  836. .nf
  837. HEAD:refs/heads/<head>
  838. .fi
  839. .if n \{\
  840. .RE
  841. .\}
  842. .SH "CONFIGURED REMOTE\-TRACKING BRANCHES"
  843. .sp
  844. You often interact with the same remote repository by regularly and repeatedly fetching from it\&. In order to keep track of the progress of such a remote repository, \fBgit\fR \fBfetch\fR allows you to configure \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR configuration variables\&.
  845. .sp
  846. Typically such a variable may look like this:
  847. .sp
  848. .if n \{\
  849. .RS 4
  850. .\}
  851. .nf
  852. [remote "origin"]
  853. fetch = +refs/heads/*:refs/remotes/origin/*
  854. .fi
  855. .if n \{\
  856. .RE
  857. .\}
  858. .sp
  859. This configuration is used in two ways:
  860. .sp
  861. .RS 4
  862. .ie n \{\
  863. \h'-04'\(bu\h'+03'\c
  864. .\}
  865. .el \{\
  866. .sp -1
  867. .IP \(bu 2.3
  868. .\}
  869. When
  870. \fBgit\fR
  871. \fBfetch\fR
  872. is run without specifying what branches and/or tags to fetch on the command line, e\&.g\&.
  873. \fBgit\fR
  874. \fBfetch\fR
  875. \fBorigin\fR
  876. or
  877. \fBgit\fR
  878. \fBfetch\fR,
  879. \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR
  880. values are used as the refspecs\(em\:they specify which refs to fetch and which local refs to update\&. The example above will fetch all branches that exist in the
  881. \fBorigin\fR
  882. (i\&.e\&. any ref that matches the left\-hand side of the value,
  883. \fBrefs/heads/\fR*) and update the corresponding remote\-tracking branches in the
  884. \fBrefs/remotes/origin/\fR* hierarchy\&.
  885. .RE
  886. .sp
  887. .RS 4
  888. .ie n \{\
  889. \h'-04'\(bu\h'+03'\c
  890. .\}
  891. .el \{\
  892. .sp -1
  893. .IP \(bu 2.3
  894. .\}
  895. When
  896. \fBgit\fR
  897. \fBfetch\fR
  898. is run with explicit branches and/or tags to fetch on the command line, e\&.g\&.
  899. \fBgit\fR
  900. \fBfetch\fR
  901. \fBorigin\fR
  902. \fBmaster\fR, the <refspec>s given on the command line determine what are to be fetched (e\&.g\&.
  903. \fBmaster\fR
  904. in the example, which is a short\-hand for
  905. \fBmaster:\fR, which in turn means "fetch the
  906. \fImaster\fR
  907. branch but I do not explicitly say what remote\-tracking branch to update with it from the command line"), and the example command will fetch
  908. \fIonly\fR
  909. the
  910. \fImaster\fR
  911. branch\&. The
  912. \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR
  913. values determine which remote\-tracking branch, if any, is updated\&. When used in this way, the
  914. \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR
  915. values do not have any effect in deciding
  916. \fIwhat\fR
  917. gets fetched (i\&.e\&. the values are not used as refspecs when the command\-line lists refspecs); they are only used to decide
  918. \fIwhere\fR
  919. the refs that are fetched are stored by acting as a mapping\&.
  920. .RE
  921. .sp
  922. The latter use of the \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR values can be overridden by giving the \fB\-\-refmap=\fR\fI<refspec>\fR parameter(s) on the command line\&.
  923. .SH "PRUNING"
  924. .sp
  925. Git has a default disposition of keeping data unless it\(cqs explicitly thrown away; this extends to holding onto local references to branches on remotes that have themselves deleted those branches\&.
  926. .sp
  927. If left to accumulate, these stale references might make performance worse on big and busy repos that have a lot of branch churn, and e\&.g\&. make the output of commands like \fBgit\fR \fBbranch\fR \fB\-a\fR \fB\-\-contains\fR \fI<commit>\fR needlessly verbose, as well as impacting anything else that\(cqll work with the complete set of known references\&.
  928. .sp
  929. These remote\-tracking references can be deleted as a one\-off with either of:
  930. .sp
  931. .if n \{\
  932. .RS 4
  933. .\}
  934. .nf
  935. # While fetching
  936. $ git fetch \-\-prune <name>
  937. # Only prune, don\*(Aqt fetch
  938. $ git remote prune <name>
  939. .fi
  940. .if n \{\
  941. .RE
  942. .\}
  943. .sp
  944. To prune references as part of your normal workflow without needing to remember to run that, set \fBfetch\&.prune\fR globally, or \fBremote\&.\fR\fI<name>\fR\fB\&.prune\fR per\-remote in the config\&. See \fBgit-config\fR(1)\&.
  945. .sp
  946. Here\(cqs where things get tricky and more specific\&. The pruning feature doesn\(cqt actually care about branches, instead it\(cqll prune local \(<-\(-> remote\-references as a function of the refspec of the remote (see \fI<refspec>\fR and CONFIGURED REMOTE\-TRACKING BRANCHES above)\&.
  947. .sp
  948. Therefore if the refspec for the remote includes e\&.g\&. \fBrefs/tags/\fR*:refs/tags/*, or you manually run e\&.g\&. \fBgit\fR \fBfetch\fR \fB\-\-prune\fR \fI<name>\fR "refs/tags/*:refs/tags/*" it won\(cqt be stale remote tracking branches that are deleted, but any local tag that doesn\(cqt exist on the remote\&.
  949. .sp
  950. This might not be what you expect, i\&.e\&. you want to prune remote \fI<name>\fR, but also explicitly fetch tags from it, so when you fetch from it you delete all your local tags, most of which may not have come from the \fI<name>\fR remote in the first place\&.
  951. .sp
  952. So be careful when using this with a refspec like \fBrefs/tags/\fR*:refs/tags/*, or any other refspec which might map references from multiple remotes to the same local namespace\&.
  953. .sp
  954. Since keeping up\-to\-date with both branches and tags on the remote is a common use\-case the \fB\-\-prune\-tags\fR option can be supplied along with \fB\-\-prune\fR to prune local tags that don\(cqt exist on the remote, and force\-update those tags that differ\&. Tag pruning can also be enabled with \fBfetch\&.pruneTags\fR or \fBremote\&.\fR\fI<name>\fR\fB\&.pruneTags\fR in the config\&. See \fBgit-config\fR(1)\&.
  955. .sp
  956. The \fB\-\-prune\-tags\fR option is equivalent to having \fBrefs/tags/\fR*:refs/tags/* declared in the refspecs of the remote\&. This can lead to some seemingly strange interactions:
  957. .sp
  958. .if n \{\
  959. .RS 4
  960. .\}
  961. .nf
  962. # These both fetch tags
  963. $ git fetch \-\-no\-tags origin \*(Aqrefs/tags/*:refs/tags/*\*(Aq
  964. $ git fetch \-\-no\-tags \-\-prune\-tags origin
  965. .fi
  966. .if n \{\
  967. .RE
  968. .\}
  969. .sp
  970. The reason it doesn\(cqt error out when provided without \fB\-\-prune\fR or its config versions is for flexibility of the configured versions, and to maintain a 1=1 mapping between what the command line flags do, and what the configuration versions do\&.
  971. .sp
  972. It\(cqs reasonable to e\&.g\&. configure \fBfetch\&.pruneTags=true\fR in \fB~/\&.gitconfig\fR to have tags pruned whenever \fBgit\fR \fBfetch\fR \fB\-\-prune\fR is run, without making every invocation of \fBgit\fR \fBfetch\fR without \fB\-\-prune\fR an error\&.
  973. .sp
  974. Pruning tags with \fB\-\-prune\-tags\fR also works when fetching a URL instead of a named remote\&. These will all prune tags not found on origin:
  975. .sp
  976. .if n \{\
  977. .RS 4
  978. .\}
  979. .nf
  980. $ git fetch origin \-\-prune \-\-prune\-tags
  981. $ git fetch origin \-\-prune \*(Aqrefs/tags/*:refs/tags/*\*(Aq
  982. $ git fetch <url\-of\-origin> \-\-prune \-\-prune\-tags
  983. $ git fetch <url\-of\-origin> \-\-prune \*(Aqrefs/tags/*:refs/tags/*\*(Aq
  984. .fi
  985. .if n \{\
  986. .RE
  987. .\}
  988. .SH "OUTPUT"
  989. .sp
  990. The output of "git fetch" depends on the transport method used; this section describes the output when fetching over the Git protocol (either locally or via ssh) and Smart HTTP protocol\&.
  991. .sp
  992. The status of the fetch is output in tabular form, with each line representing the status of a single ref\&. Each line is of the form:
  993. .sp
  994. .if n \{\
  995. .RS 4
  996. .\}
  997. .nf
  998. <flag> <summary> <from> \-> <to> [<reason>]
  999. .fi
  1000. .if n \{\
  1001. .RE
  1002. .\}
  1003. .sp
  1004. When using \fB\-\-porcelain\fR, the output format is intended to be machine\-parseable\&. In contrast to the human\-readable output formats it thus prints to standard output instead of standard error\&. Each line is of the form:
  1005. .sp
  1006. .if n \{\
  1007. .RS 4
  1008. .\}
  1009. .nf
  1010. <flag> <old\-object\-id> <new\-object\-id> <local\-reference>
  1011. .fi
  1012. .if n \{\
  1013. .RE
  1014. .\}
  1015. .sp
  1016. The status of up\-to\-date refs is shown only if the \-\-verbose option is used\&.
  1017. .sp
  1018. In compact output mode, specified with configuration variable fetch\&.output, if either entire \fI<from>\fR or \fI<to>\fR is found in the other string, it will be substituted with * in the other string\&. For example, \fBmaster\fR \fB\-\fR> \fBorigin/master\fR becomes \fBmaster\fR \fB\-\fR> \fBorigin/\fR*\&.
  1019. .PP
  1020. flag
  1021. .RS 4
  1022. A single character indicating the status of the ref:
  1023. .PP
  1024. (space)
  1025. .RS 4
  1026. for a successfully fetched fast\-forward;
  1027. .RE
  1028. .PP
  1029. \fB+\fR
  1030. .RS 4
  1031. for a successful forced update;
  1032. .RE
  1033. .PP
  1034. \fB\-\fR
  1035. .RS 4
  1036. for a successfully pruned ref;
  1037. .RE
  1038. .PP
  1039. \fBt\fR
  1040. .RS 4
  1041. for a successful tag update;
  1042. .RE
  1043. .PP
  1044. *
  1045. .RS 4
  1046. for a successfully fetched new ref;
  1047. .RE
  1048. .PP
  1049. !
  1050. .RS 4
  1051. for a ref that was rejected or failed to update; and
  1052. .RE
  1053. .PP
  1054. \fB=\fR
  1055. .RS 4
  1056. for a ref that was up to date and did not need fetching\&.
  1057. .RE
  1058. .RE
  1059. .PP
  1060. summary
  1061. .RS 4
  1062. For a successfully fetched ref, the summary shows the old and new values of the ref in a form suitable for using as an argument to
  1063. \fBgit\fR
  1064. \fBlog\fR
  1065. (this is
  1066. \fI<old>\fR\fB\&.\&.\fR\fI<new>\fR
  1067. in most cases, and
  1068. \fI<old>\fR\fB\&.\&.\&.\fR\fI<new>\fR
  1069. for forced non\-fast\-forward updates)\&.
  1070. .RE
  1071. .PP
  1072. from
  1073. .RS 4
  1074. The name of the remote ref being fetched from, minus its
  1075. \fBrefs/\fR\fI<type>\fR\fB/\fR
  1076. prefix\&. In the case of deletion, the name of the remote ref is "(none)"\&.
  1077. .RE
  1078. .PP
  1079. to
  1080. .RS 4
  1081. The name of the local ref being updated, minus its
  1082. \fBrefs/\fR\fI<type>\fR\fB/\fR
  1083. prefix\&.
  1084. .RE
  1085. .PP
  1086. reason
  1087. .RS 4
  1088. A human\-readable explanation\&. In the case of successfully fetched refs, no explanation is needed\&. For a failed ref, the reason for failure is described\&.
  1089. .RE
  1090. .SH "EXAMPLES"
  1091. .sp
  1092. .RS 4
  1093. .ie n \{\
  1094. \h'-04'\(bu\h'+03'\c
  1095. .\}
  1096. .el \{\
  1097. .sp -1
  1098. .IP \(bu 2.3
  1099. .\}
  1100. Update the remote\-tracking branches:
  1101. .sp
  1102. .if n \{\
  1103. .RS 4
  1104. .\}
  1105. .nf
  1106. $ git fetch origin
  1107. .fi
  1108. .if n \{\
  1109. .RE
  1110. .\}
  1111. .sp
  1112. The above command copies all branches from the remote
  1113. \fBrefs/heads/\fR
  1114. namespace and stores them to the local
  1115. \fBrefs/remotes/origin/\fR
  1116. namespace, unless the
  1117. \fBremote\&.\fR\fI<repository>\fR\fB\&.fetch\fR
  1118. option is used to specify a non\-default refspec\&.
  1119. .RE
  1120. .sp
  1121. .RS 4
  1122. .ie n \{\
  1123. \h'-04'\(bu\h'+03'\c
  1124. .\}
  1125. .el \{\
  1126. .sp -1
  1127. .IP \(bu 2.3
  1128. .\}
  1129. Using refspecs explicitly:
  1130. .sp
  1131. .if n \{\
  1132. .RS 4
  1133. .\}
  1134. .nf
  1135. $ git fetch origin +seen:seen maint:tmp
  1136. .fi
  1137. .if n \{\
  1138. .RE
  1139. .\}
  1140. .sp
  1141. This updates (or creates, as necessary) branches
  1142. \fBseen\fR
  1143. and
  1144. \fBtmp\fR
  1145. in the local repository by fetching from the branches (respectively)
  1146. \fBseen\fR
  1147. and
  1148. \fBmaint\fR
  1149. from the remote repository\&.
  1150. .sp
  1151. The
  1152. \fBseen\fR
  1153. branch will be updated even if it does not fast\-forward, because it is prefixed with a plus sign;
  1154. \fBtmp\fR
  1155. will not be\&.
  1156. .RE
  1157. .sp
  1158. .RS 4
  1159. .ie n \{\
  1160. \h'-04'\(bu\h'+03'\c
  1161. .\}
  1162. .el \{\
  1163. .sp -1
  1164. .IP \(bu 2.3
  1165. .\}
  1166. Peek at a remote\(cqs branch, without configuring the remote in your local repository:
  1167. .sp
  1168. .if n \{\
  1169. .RS 4
  1170. .\}
  1171. .nf
  1172. $ git fetch git://git\&.kernel\&.org/pub/scm/git/git\&.git maint
  1173. $ git log FETCH_HEAD
  1174. .fi
  1175. .if n \{\
  1176. .RE
  1177. .\}
  1178. .sp
  1179. The first command fetches the
  1180. \fBmaint\fR
  1181. branch from the repository at
  1182. \fBgit://git\&.kernel\&.org/pub/scm/git/git\&.git\fR
  1183. and the second command uses
  1184. \fBFETCH_HEAD\fR
  1185. to examine the branch with
  1186. \fBgit-log\fR(1)\&. The fetched objects will eventually be removed by git\(cqs built\-in housekeeping (see
  1187. \fBgit-gc\fR(1))\&.
  1188. .RE
  1189. .SH "SECURITY"
  1190. .sp
  1191. The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared\&. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository\&. This applies to both clients and servers\&. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository\&.
  1192. .sp
  1193. The known attack vectors are as follows:
  1194. .sp
  1195. .RS 4
  1196. .ie n \{\
  1197. \h'-04' 1.\h'+01'\c
  1198. .\}
  1199. .el \{\
  1200. .sp -1
  1201. .IP " 1." 4.2
  1202. .\}
  1203. The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them\&. The attacker chooses an object ID X to steal and sends a ref to X, but isn\(cqt required to send the content of X because the victim already has it\&. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later\&. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it\&. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge\&.)
  1204. .RE
  1205. .sp
  1206. .RS 4
  1207. .ie n \{\
  1208. \h'-04' 2.\h'+01'\c
  1209. .\}
  1210. .el \{\
  1211. .sp -1
  1212. .IP " 2." 4.2
  1213. .\}
  1214. As in #1, the attacker chooses an object ID X to steal\&. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X\&. The delta reveals regions of X that are similar to Y to the attacker\&.
  1215. .RE
  1216. .SH "CONFIGURATION"
  1217. .sp
  1218. Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
  1219. .PP
  1220. fetch\&.recurseSubmodules
  1221. .RS 4
  1222. This option controls whether
  1223. \fBgit\fR
  1224. \fBfetch\fR
  1225. (and the underlying fetch in
  1226. \fBgit\fR
  1227. \fBpull\fR) will recursively fetch into populated submodules\&. This option can be set either to a boolean value or to
  1228. \fIon\-demand\fR\&. Setting it to a boolean changes the behavior of fetch and pull to recurse unconditionally into submodules when set to true or to not recurse at all when set to false\&. When set to
  1229. \fIon\-demand\fR, fetch and pull will only recurse into a populated submodule when its superproject retrieves a commit that updates the submodule\(cqs reference\&. Defaults to
  1230. \fIon\-demand\fR, or to the value of
  1231. \fIsubmodule\&.recurse\fR
  1232. if set\&.
  1233. .RE
  1234. .PP
  1235. fetch\&.fsckObjects
  1236. .RS 4
  1237. If it is set to true, git\-fetch\-pack will check all fetched objects\&. See
  1238. \fBtransfer\&.fsckObjects\fR
  1239. for what\(cqs checked\&. Defaults to false\&. If not set, the value of
  1240. \fBtransfer\&.fsckObjects\fR
  1241. is used instead\&.
  1242. .RE
  1243. .PP
  1244. fetch\&.fsck\&.<msg\-id>
  1245. .RS 4
  1246. Acts like
  1247. \fBfsck\&.\fR\fI<msg\-id>\fR, but is used by
  1248. \fBgit-fetch-pack\fR(1)
  1249. instead of
  1250. \fBgit-fsck\fR(1)\&. See the
  1251. \fBfsck\&.\fR\fI<msg\-id>\fR
  1252. documentation for details\&.
  1253. .RE
  1254. .PP
  1255. fetch\&.fsck\&.skipList
  1256. .RS 4
  1257. Acts like
  1258. \fBfsck\&.skipList\fR, but is used by
  1259. \fBgit-fetch-pack\fR(1)
  1260. instead of
  1261. \fBgit-fsck\fR(1)\&. See the
  1262. \fBfsck\&.skipList\fR
  1263. documentation for details\&.
  1264. .RE
  1265. .PP
  1266. fetch\&.unpackLimit
  1267. .RS 4
  1268. If the number of objects fetched over the Git native transfer is below this limit, then the objects will be unpacked into loose object files\&. However if the number of received objects equals or exceeds this limit then the received pack will be stored as a pack, after adding any missing delta bases\&. Storing the pack from a push can make the push operation complete faster, especially on slow filesystems\&. If not set, the value of
  1269. \fBtransfer\&.unpackLimit\fR
  1270. is used instead\&.
  1271. .RE
  1272. .PP
  1273. fetch\&.prune
  1274. .RS 4
  1275. If true, fetch will automatically behave as if the
  1276. \fB\-\-prune\fR
  1277. option was given on the command line\&. See also
  1278. \fBremote\&.\fR\fI<name>\fR\fB\&.prune\fR
  1279. and the PRUNING section of
  1280. \fBgit-fetch\fR(1)\&.
  1281. .RE
  1282. .PP
  1283. fetch\&.pruneTags
  1284. .RS 4
  1285. If true, fetch will automatically behave as if the
  1286. \fBrefs/tags/\fR*:refs/tags/* refspec was provided when pruning, if not set already\&. This allows for setting both this option and
  1287. \fBfetch\&.prune\fR
  1288. to maintain a 1=1 mapping to upstream refs\&. See also
  1289. \fBremote\&.\fR\fI<name>\fR\fB\&.pruneTags\fR
  1290. and the PRUNING section of
  1291. \fBgit-fetch\fR(1)\&.
  1292. .RE
  1293. .PP
  1294. fetch\&.all
  1295. .RS 4
  1296. If true, fetch will attempt to update all available remotes\&. This behavior can be overridden by passing
  1297. \fB\-\-no\-all\fR
  1298. or by explicitly specifying one or more remote(s) to fetch from\&. Defaults to false\&.
  1299. .RE
  1300. .PP
  1301. fetch\&.output
  1302. .RS 4
  1303. Control how ref update status is printed\&. Valid values are
  1304. \fBfull\fR
  1305. and
  1306. \fBcompact\fR\&. Default value is
  1307. \fBfull\fR\&. See the OUTPUT section in
  1308. \fBgit-fetch\fR(1)
  1309. for details\&.
  1310. .RE
  1311. .PP
  1312. fetch\&.negotiationAlgorithm
  1313. .RS 4
  1314. Control how information about the commits in the local repository is sent when negotiating the contents of the packfile to be sent by the server\&. Set to "consecutive" to use an algorithm that walks over consecutive commits checking each one\&. Set to "skipping" to use an algorithm that skips commits in an effort to converge faster, but may result in a larger\-than\-necessary packfile; or set to "noop" to not send any information at all, which will almost certainly result in a larger\-than\-necessary packfile, but will skip the negotiation step\&. Set to "default" to override settings made previously and use the default behaviour\&. The default is normally "consecutive", but if
  1315. \fBfeature\&.experimental\fR
  1316. is true, then the default is "skipping"\&. Unknown values will cause
  1317. \fIgit fetch\fR
  1318. to error out\&.
  1319. .sp
  1320. See also the
  1321. \fB\-\-negotiate\-only\fR
  1322. and
  1323. \fB\-\-negotiation\-tip\fR
  1324. options to
  1325. \fBgit-fetch\fR(1)\&.
  1326. .RE
  1327. .PP
  1328. fetch\&.showForcedUpdates
  1329. .RS 4
  1330. Set to false to enable
  1331. \fB\-\-no\-show\-forced\-updates\fR
  1332. in
  1333. \fBgit-fetch\fR(1)
  1334. and
  1335. \fBgit-pull\fR(1)
  1336. commands\&. Defaults to true\&.
  1337. .RE
  1338. .PP
  1339. fetch\&.parallel
  1340. .RS 4
  1341. Specifies the maximal number of fetch operations to be run in parallel at a time (submodules, or remotes when the
  1342. \fB\-\-multiple\fR
  1343. option of
  1344. \fBgit-fetch\fR(1)
  1345. is in effect)\&.
  1346. .sp
  1347. A value of 0 will give some reasonable default\&. If unset, it defaults to 1\&.
  1348. .sp
  1349. For submodules, this setting can be overridden using the
  1350. \fBsubmodule\&.fetchJobs\fR
  1351. config setting\&.
  1352. .RE
  1353. .PP
  1354. fetch\&.writeCommitGraph
  1355. .RS 4
  1356. Set to true to write a commit\-graph after every
  1357. \fBgit\fR
  1358. \fBfetch\fR
  1359. command that downloads a pack\-file from a remote\&. Using the
  1360. \fB\-\-split\fR
  1361. option, most executions will create a very small commit\-graph file on top of the existing commit\-graph file(s)\&. Occasionally, these files will merge and the write may take longer\&. Having an updated commit\-graph file helps performance of many Git commands, including
  1362. \fBgit\fR
  1363. \fBmerge\-base\fR,
  1364. \fBgit\fR
  1365. \fBpush\fR
  1366. \fB\-f\fR, and
  1367. \fBgit\fR
  1368. \fBlog\fR
  1369. \fB\-\-graph\fR\&. Defaults to false\&.
  1370. .RE
  1371. .PP
  1372. fetch\&.bundleURI
  1373. .RS 4
  1374. This value stores a URI for downloading Git object data from a bundle URI before performing an incremental fetch from the origin Git server\&. This is similar to how the
  1375. \fB\-\-bundle\-uri\fR
  1376. option behaves in
  1377. \fBgit-clone\fR(1)\&.
  1378. \fBgit\fR
  1379. \fBclone\fR
  1380. \fB\-\-bundle\-uri\fR
  1381. will set the
  1382. \fBfetch\&.bundleURI\fR
  1383. value if the supplied bundle URI contains a bundle list that is organized for incremental fetches\&.
  1384. .sp
  1385. If you modify this value and your repository has a
  1386. \fBfetch\&.bundleCreationToken\fR
  1387. value, then remove that
  1388. \fBfetch\&.bundleCreationToken\fR
  1389. value before fetching from the new bundle URI\&.
  1390. .RE
  1391. .PP
  1392. fetch\&.bundleCreationToken
  1393. .RS 4
  1394. When using
  1395. \fBfetch\&.bundleURI\fR
  1396. to fetch incrementally from a bundle list that uses the "creationToken" heuristic, this config value stores the maximum
  1397. \fBcreationToken\fR
  1398. value of the downloaded bundles\&. This value is used to prevent downloading bundles in the future if the advertised
  1399. \fBcreationToken\fR
  1400. is not strictly larger than this value\&.
  1401. .sp
  1402. The creation token values are chosen by the provider serving the specific bundle URI\&. If you modify the URI at
  1403. \fBfetch\&.bundleURI\fR, then be sure to remove the value for the
  1404. \fBfetch\&.bundleCreationToken\fR
  1405. value before fetching\&.
  1406. .RE
  1407. .SH "BUGS"
  1408. .sp
  1409. Using \-\-recurse\-submodules can only fetch new commits in submodules that are present locally e\&.g\&. in \fB$GIT_DIR/modules/\fR\&. 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\&. This is expected to be fixed in a future Git version\&.
  1410. .SH "SEE ALSO"
  1411. .sp
  1412. \fBgit-pull\fR(1)
  1413. .SH "GIT"
  1414. .sp
  1415. Part of the \fBgit\fR(1) suite