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

NAME

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

SYNOPSIS

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

DESCRIPTION

18       Fetches named heads or tags from one or more other repositories, along
19       with the objects necessary to complete them.
20
21       The ref names and their object names of fetched refs are stored in
22       .git/FETCH_HEAD. This information is left for a later merge operation
23       done by git merge.
24
25       When <refspec> stores the fetched result in tracking branches, the tags
26       that point at these branches are automatically followed. This is done
27       by first fetching from the remote using the given <refspec>s, and if
28       the repository has objects that are pointed by remote tags that it does
29       not yet have, then fetch those missing tags. If the other end has tags
30       that point at branches you are not interested in, you will not get
31       them.
32
33       git fetch can fetch from either a single named repository, or or from
34       several repositories at once if <group> is given and there is a
35       remotes.<group> entry in the configuration file. (See git-config(1)).
36

OPTIONS

38       --all
39           Fetch all remotes.
40
41       -a, --append
42           Append ref names and object names of fetched refs to the existing
43           contents of .git/FETCH_HEAD. Without this option old data in
44           .git/FETCH_HEAD will be overwritten.
45
46       --depth=<depth>
47           Deepen the history of a shallow repository created by git clone
48           with --depth=<depth> option (see git-clone(1)) by the specified
49           number of commits.
50
51       --dry-run
52           Show what would be done, without making any changes.
53
54       -f, --force
55           When git fetch is used with <rbranch>:<lbranch> refspec, it refuses
56           to update the local branch <lbranch> unless the remote branch
57           <rbranch> it fetches is a descendant of <lbranch>. This option
58           overrides that check.
59
60       -k, --keep
61           Keep downloaded pack.
62
63       --multiple
64           Allow several <repository> and <group> arguments to be specified.
65           No <refspec>s may be specified.
66
67       --prune
68           After fetching, remove any remote tracking branches which no longer
69           exist on the remote.
70
71       -n, --no-tags
72           By default, tags that point at objects that are downloaded from the
73           remote repository are fetched and stored locally. This option
74           disables this automatic tag following.
75
76       -t, --tags
77           Most of the tags are fetched automatically as branch heads are
78           downloaded, but tags that do not point at objects reachable from
79           the branch heads that are being tracked will not be fetched by this
80           mechanism. This flag lets all tags and their associated objects be
81           downloaded.
82
83       -u, --update-head-ok
84           By default git fetch refuses to update the head which corresponds
85           to the current branch. This flag disables the check. This is purely
86           for the internal use for git pull to communicate with git fetch,
87           and unless you are implementing your own Porcelain you are not
88           supposed to use it.
89
90       --upload-pack <upload-pack>
91           When given, and the repository to fetch from is handled by git
92           fetch-pack, --exec=<upload-pack> is passed to the command to
93           specify non-default path for the command run on the other end.
94
95       -q, --quiet
96           Pass --quiet to git-fetch-pack and silence any other internally
97           used git commands. Progress is not reported to the standard error
98           stream.
99
100       -v, --verbose
101           Be verbose.
102
103       --progress
104           Progress status is reported on the standard error stream by default
105           when it is attached to a terminal, unless -q is specified. This
106           flag forces progress status even if the standard error stream is
107           not directed to a terminal.
108
109       <repository>
110           The "remote" repository that is the source of a fetch or pull
111           operation. This parameter can be either a URL (see the section GIT
112           URLS below) or the name of a remote (see the section REMOTES
113           below).
114
115       <group>
116           A name referring to a list of repositories as the value of
117           remotes.<group> in the configuration file. (See git-config(1)).
118
119       <refspec>
120           The format of a <refspec> parameter is an optional plus +, followed
121           by the source ref <src>, followed by a colon :, followed by the
122           destination ref <dst>.
123
124           The remote ref that matches <src> is fetched, and if <dst> is not
125           empty string, the local ref that matches it is fast-forwarded using
126           <src>. If the optional plus + is used, the local ref is updated
127           even if it does not result in a fast-forward update.
128
129               Note
130               If the remote branch from which you want to pull is modified in
131               non-linear ways such as being rewound and rebased frequently,
132               then a pull will attempt a merge with an older version of
133               itself, likely conflict, and fail. It is under these conditions
134               that you would want to use the + sign to indicate
135               non-fast-forward updates will be needed. There is currently no
136               easy way to determine or declare that a branch will be made
137               available in a repository with this behavior; the pulling user
138               simply must know this is the expected usage pattern for a
139               branch.
140
141               Note
142               You never do your own development on branches that appear on
143               the right hand side of a <refspec> colon on Pull: lines; they
144               are to be updated by git fetch. If you intend to do development
145               derived from a remote branch B, have a Pull: line to track it
146               (i.e.  Pull: B:remote-B), and have a separate branch my-B to do
147               your development on top of it. The latter is created by git
148               branch my-B remote-B (or its equivalent git checkout -b my-B
149               remote-B). Run git fetch to keep track of the progress of the
150               remote side, and when you see something new on the remote
151               branch, merge it into your development branch with git pull .
152               remote-B, while you are on my-B branch.
153
154               Note
155               There is a difference between listing multiple <refspec>
156               directly on git pull command line and having multiple Pull:
157               <refspec> lines for a <repository> and running git pull command
158               without any explicit <refspec> parameters. <refspec> listed
159               explicitly on the command line are always merged into the
160               current branch after fetching. In other words, if you list more
161               than one remote refs, you would be making an Octopus. While git
162               pull run without any explicit <refspec> parameter takes default
163               <refspec>s from Pull: lines, it merges only the first <refspec>
164               found into the current branch, after fetching all the remote
165               refs. This is because making an Octopus from remote refs is
166               rarely done, while keeping track of multiple remote heads in
167               one-go by fetching more than one is often useful.
168           Some short-cut notations are also supported.
169
170           ·    tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>;
171               it requests fetching everything up to the given tag.
172
173           ·   A parameter <ref> without a colon is equivalent to <ref>: when
174               pulling/fetching, so it merges <ref> into the current branch
175               without storing the remote branch anywhere locally
176

GIT URLS

178       In general, URLs contain information about the transport protocol, the
179       address of the remote server, and the path to the repository. Depending
180       on the transport protocol, some of this information may be absent.
181
182       Git natively supports ssh, git, http, https, ftp, ftps, and rsync
183       protocols. The following syntaxes may be used with them:
184
185       ·   ssh://[user@]host.xz[:port]/path/to/repo.git/
186
187       ·   git://host.xz[:port]/path/to/repo.git/
188
189       ·   http[s]://host.xz[:port]/path/to/repo.git/
190
191       ·   ftp[s]://host.xz[:port]/path/to/repo.git/
192
193       ·   rsync://host.xz/path/to/repo.git/
194
195       An alternative scp-like syntax may also be used with the ssh protocol:
196
197       ·   [user@]host.xz:path/to/repo.git/
198
199       The ssh and git protocols additionally support ~username expansion:
200
201       ·   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
202
203       ·   git://host.xz[:port]/~[user]/path/to/repo.git/
204
205       ·   [user@]host.xz:/~[user]/path/to/repo.git/
206
207       For local respositories, also supported by git natively, the following
208       syntaxes may be used:
209
210       ·   /path/to/repo.git/
211
212       ·    file:///path/to/repo.git/
213
214       These two syntaxes are mostly equivalent, except when cloning, when the
215       former implies --local option. See git-clone(1) for details.
216
217       When git doesn’t know how to handle a certain transport protocol, it
218       attempts to use the remote-<transport> remote helper, if one exists. To
219       explicitly request a remote helper, the following syntax may be used:
220
221       ·   <transport>::<address>
222
223       where <address> may be a path, a server and path, or an arbitrary
224       URL-like string recognized by the specific remote helper being invoked.
225       See git-remote-helpers(1) for details.
226
227       If there are a large number of similarly-named remote repositories and
228       you want to use a different format for them (such that the URLs you use
229       will be rewritten into URLs that work), you can create a configuration
230       section of the form:
231
232                   [url "<actual url base>"]
233                           insteadOf = <other url base>
234
235
236       For example, with this:
237
238                   [url "git://git.host.xz/"]
239                           insteadOf = host.xz:/path/to/
240                           insteadOf = work:
241
242
243       a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
244       rewritten in any context that takes a URL to be
245       "git://git.host.xz/repo.git".
246
247       If you want to rewrite URLs for push only, you can create a
248       configuration section of the form:
249
250                   [url "<actual url base>"]
251                           pushInsteadOf = <other url base>
252
253
254       For example, with this:
255
256                   [url "ssh://example.org/"]
257                           pushInsteadOf = git://example.org/
258
259
260       a URL like "git://example.org/path/to/repo.git" will be rewritten to
261       "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
262       use the original URL.
263

REMOTES

265       The name of one of the following can be used instead of a URL as
266       <repository> argument:
267
268       ·   a remote in the git configuration file: $GIT_DIR/config,
269
270       ·   a file in the $GIT_DIR/remotes directory, or
271
272       ·   a file in the $GIT_DIR/branches directory.
273
274       All of these also allow you to omit the refspec from the command line
275       because they each contain a refspec which git will use by default.
276
277   Named remote in configuration file
278       You can choose to provide the name of a remote which you had previously
279       configured using git-remote(1), git-config(1) or even by a manual edit
280       to the $GIT_DIR/config file. The URL of this remote will be used to
281       access the repository. The refspec of this remote will be used by
282       default when you do not provide a refspec on the command line. The
283       entry in the config file would appear like this:
284
285                   [remote "<name>"]
286                           url = <url>
287                           pushurl = <pushurl>
288                           push = <refspec>
289                           fetch = <refspec>
290
291
292       The <pushurl> is used for pushes only. It is optional and defaults to
293       <url>.
294
295   Named file in $GIT_DIR/remotes
296       You can choose to provide the name of a file in $GIT_DIR/remotes. The
297       URL in this file will be used to access the repository. The refspec in
298       this file will be used as default when you do not provide a refspec on
299       the command line. This file should have the following format:
300
301                   URL: one of the above URL format
302                   Push: <refspec>
303                   Pull: <refspec>
304
305
306       Push: lines are used by git push and Pull: lines are used by git pull
307       and git fetch. Multiple Push: and Pull: lines may be specified for
308       additional branch mappings.
309
310   Named file in $GIT_DIR/branches
311       You can choose to provide the name of a file in $GIT_DIR/branches. The
312       URL in this file will be used to access the repository. This file
313       should have the following format:
314
315                   <url>#<head>
316
317
318       <url> is required; #<head> is optional.
319
320       Depending on the operation, git will use one of the following refspecs,
321       if you don’t provide one on the command line. <branch> is the name of
322       this file in $GIT_DIR/branches and <head> defaults to master.
323
324       git fetch uses:
325
326                   refs/heads/<head>:refs/heads/<branch>
327
328
329       git push uses:
330
331                   HEAD:refs/heads/<head>
332
333

EXAMPLES

335       ·   Update the remote-tracking branches:
336
337               $ git fetch origin
338
339           The above command copies all branches from the remote refs/heads/
340           namespace and stores them to the local refs/remotes/origin/
341           namespace, unless the branch.<name>.fetch option is used to specify
342           a non-default refspec.
343
344       ·   Using refspecs explicitly:
345
346               $ git fetch origin +pu:pu maint:tmp
347
348           This updates (or creates, as necessary) branches pu and tmp in the
349           local repository by fetching from the branches (respectively) pu
350           and maint from the remote repository.
351
352           The pu branch will be updated even if it is does not fast-forward,
353           because it is prefixed with a plus sign; tmp will not be.
354

SEE ALSO

356       git-pull(1)
357

AUTHOR

359       Written by Linus Torvalds <torvalds@osdl.org[1]> and Junio C Hamano
360       <gitster@pobox.com[2]>
361

DOCUMENTATION

363       Documentation by David Greaves, Junio C Hamano and the git-list
364       <git@vger.kernel.org[3]>.
365

GIT

367       Part of the git(1) suite
368

NOTES

370        1. torvalds@osdl.org
371           mailto:torvalds@osdl.org
372
373        2. gitster@pobox.com
374           mailto:gitster@pobox.com
375
376        3. git@vger.kernel.org
377           mailto:git@vger.kernel.org
378
379
380
381Git 1.7.1                         08/16/2017                      GIT-FETCH(1)
Impressum