1GIT-PULL(1) Git Manual GIT-PULL(1)
2
3
4
6 git-pull - Fetch from and integrate with another repository or a local
7 branch
8
10 git pull [<options>] [<repository> [<refspec>...]]
11
12
14 Incorporates changes from a remote repository into the current branch.
15 In its default mode, git pull is shorthand for git fetch followed by
16 git merge FETCH_HEAD.
17
18 More precisely, git pull runs git fetch with the given parameters and
19 calls git merge to merge the retrieved branch heads into the current
20 branch. With --rebase, it runs git rebase instead of git merge.
21
22 <repository> should be the name of a remote repository as passed to
23 git-fetch(1). <refspec> can name an arbitrary remote ref (for example,
24 the name of a tag) or even a collection of refs with corresponding
25 remote-tracking branches (e.g., refs/heads/*:refs/remotes/origin/*),
26 but usually it is the name of a branch in the remote repository.
27
28 Default values for <repository> and <branch> are read from the "remote"
29 and "merge" configuration for the current branch as set by git-
30 branch(1) --track.
31
32 Assume the following history exists and the current branch is "master":
33
34 A---B---C master on origin
35 /
36 D---E---F---G master
37 ^
38 origin/master in your repository
39
40
41 Then "git pull" will fetch and replay the changes from the remote
42 master branch since it diverged from the local master (i.e., E) until
43 its current commit (C) on top of master and record the result in a new
44 commit along with the names of the two parent commits and a log message
45 from the user describing the changes.
46
47 A---B---C origin/master
48 / \
49 D---E---F---G---H master
50
51
52 See git-merge(1) for details, including how conflicts are presented and
53 handled.
54
55 In Git 1.7.0 or later, to cancel a conflicting merge, use git reset
56 --merge. Warning: In older versions of Git, running git pull with
57 uncommitted changes is discouraged: while possible, it leaves you in a
58 state that may be hard to back out of in the case of a conflict.
59
60 If any of the remote changes overlap with local uncommitted changes,
61 the merge will be automatically canceled and the work tree untouched.
62 It is generally best to get any local changes in working order before
63 pulling or stash them away with git-stash(1).
64
66 -q, --quiet
67 This is passed to both underlying git-fetch to squelch reporting of
68 during transfer, and underlying git-merge to squelch output during
69 merging.
70
71 -v, --verbose
72 Pass --verbose to git-fetch and git-merge.
73
74 --[no-]recurse-submodules[=yes|on-demand|no]
75 This option controls if new commits of all populated submodules
76 should be fetched and updated, too (see git-config(1) and
77 gitmodules(5)).
78
79 If the checkout is done via rebase, local submodule commits are
80 rebased as well.
81
82 If the update is done via merge, the submodule conflicts are
83 resolved and checked out.
84
85 Options related to merging
86 --commit, --no-commit
87 Perform the merge and commit the result. This option can be used to
88 override --no-commit.
89
90 With --no-commit perform the merge but pretend the merge failed and
91 do not autocommit, to give the user a chance to inspect and further
92 tweak the merge result before committing.
93
94 --edit, -e, --no-edit
95 Invoke an editor before committing successful mechanical merge to
96 further edit the auto-generated merge message, so that the user can
97 explain and justify the merge. The --no-edit option can be used to
98 accept the auto-generated message (this is generally discouraged).
99
100 Older scripts may depend on the historical behaviour of not
101 allowing the user to edit the merge log message. They will see an
102 editor opened when they run git merge. To make it easier to adjust
103 such scripts to the updated behaviour, the environment variable
104 GIT_MERGE_AUTOEDIT can be set to no at the beginning of them.
105
106 --ff
107 When the merge resolves as a fast-forward, only update the branch
108 pointer, without creating a merge commit. This is the default
109 behavior.
110
111 --no-ff
112 Create a merge commit even when the merge resolves as a
113 fast-forward. This is the default behaviour when merging an
114 annotated (and possibly signed) tag that is not stored in its
115 natural place in refs/tags/ hierarchy.
116
117 --ff-only
118 Refuse to merge and exit with a non-zero status unless the current
119 HEAD is already up to date or the merge can be resolved as a
120 fast-forward.
121
122 -S[<keyid>], --gpg-sign[=<keyid>]
123 GPG-sign the resulting merge commit. The keyid argument is optional
124 and defaults to the committer identity; if specified, it must be
125 stuck to the option without a space.
126
127 --log[=<n>], --no-log
128 In addition to branch names, populate the log message with one-line
129 descriptions from at most <n> actual commits that are being merged.
130 See also git-fmt-merge-msg(1).
131
132 With --no-log do not list one-line descriptions from the actual
133 commits being merged.
134
135 --signoff, --no-signoff
136 Add Signed-off-by line by the committer at the end of the commit
137 log message. The meaning of a signoff depends on the project, but
138 it typically certifies that committer has the rights to submit this
139 work under the same license and agrees to a Developer Certificate
140 of Origin (see http://developercertificate.org/ for more
141 information).
142
143 With --no-signoff do not add a Signed-off-by line.
144
145 --stat, -n, --no-stat
146 Show a diffstat at the end of the merge. The diffstat is also
147 controlled by the configuration option merge.stat.
148
149 With -n or --no-stat do not show a diffstat at the end of the
150 merge.
151
152 --squash, --no-squash
153 Produce the working tree and index state as if a real merge
154 happened (except for the merge information), but do not actually
155 make a commit, move the HEAD, or record $GIT_DIR/MERGE_HEAD (to
156 cause the next git commit command to create a merge commit). This
157 allows you to create a single commit on top of the current branch
158 whose effect is the same as merging another branch (or more in case
159 of an octopus).
160
161 With --no-squash perform the merge and commit the result. This
162 option can be used to override --squash.
163
164 -s <strategy>, --strategy=<strategy>
165 Use the given merge strategy; can be supplied more than once to
166 specify them in the order they should be tried. If there is no -s
167 option, a built-in list of strategies is used instead (git
168 merge-recursive when merging a single head, git merge-octopus
169 otherwise).
170
171 -X <option>, --strategy-option=<option>
172 Pass merge strategy specific option through to the merge strategy.
173
174 --verify-signatures, --no-verify-signatures
175 Verify that the tip commit of the side branch being merged is
176 signed with a valid key, i.e. a key that has a valid uid: in the
177 default trust model, this means the signing key has been signed by
178 a trusted key. If the tip commit of the side branch is not signed
179 with a valid key, the merge is aborted.
180
181 --summary, --no-summary
182 Synonyms to --stat and --no-stat; these are deprecated and will be
183 removed in the future.
184
185 --allow-unrelated-histories
186 By default, git merge command refuses to merge histories that do
187 not share a common ancestor. This option can be used to override
188 this safety when merging histories of two projects that started
189 their lives independently. As that is a very rare occasion, no
190 configuration variable to enable this by default exists and will
191 not be added.
192
193 -r, --rebase[=false|true|merges|preserve|interactive]
194 When true, rebase the current branch on top of the upstream branch
195 after fetching. If there is a remote-tracking branch corresponding
196 to the upstream branch and the upstream branch was rebased since
197 last fetched, the rebase uses that information to avoid rebasing
198 non-local changes.
199
200 When set to merges, rebase using git rebase --rebase-merges so that
201 the local merge commits are included in the rebase (see git-
202 rebase(1) for details).
203
204 When set to preserve, rebase with the --preserve-merges option
205 passed to git rebase so that locally created merge commits will not
206 be flattened.
207
208 When false, merge the current branch into the upstream branch.
209
210 When interactive, enable the interactive mode of rebase.
211
212 See pull.rebase, branch.<name>.rebase and branch.autoSetupRebase in
213 git-config(1) if you want to make git pull always use --rebase
214 instead of merging.
215
216 Note
217 This is a potentially dangerous mode of operation. It rewrites
218 history, which does not bode well when you published that
219 history already. Do not use this option unless you have read
220 git-rebase(1) carefully.
221
222 --no-rebase
223 Override earlier --rebase.
224
225 --autostash, --no-autostash
226 Before starting rebase, stash local modifications away (see git-
227 stash(1)) if needed, and apply the stash entry when done.
228 --no-autostash is useful to override the rebase.autoStash
229 configuration variable (see git-config(1)).
230
231 This option is only valid when "--rebase" is used.
232
233 Options related to fetching
234 --all
235 Fetch all remotes.
236
237 -a, --append
238 Append ref names and object names of fetched refs to the existing
239 contents of .git/FETCH_HEAD. Without this option old data in
240 .git/FETCH_HEAD will be overwritten.
241
242 --depth=<depth>
243 Limit fetching to the specified number of commits from the tip of
244 each remote branch history. If fetching to a shallow repository
245 created by git clone with --depth=<depth> option (see git-
246 clone(1)), deepen or shorten the history to the specified number of
247 commits. Tags for the deepened commits are not fetched.
248
249 --deepen=<depth>
250 Similar to --depth, except it specifies the number of commits from
251 the current shallow boundary instead of from the tip of each remote
252 branch history.
253
254 --shallow-since=<date>
255 Deepen or shorten the history of a shallow repository to include
256 all reachable commits after <date>.
257
258 --shallow-exclude=<revision>
259 Deepen or shorten the history of a shallow repository to exclude
260 commits reachable from a specified remote branch or tag. This
261 option can be specified multiple times.
262
263 --unshallow
264 If the source repository is complete, convert a shallow repository
265 to a complete one, removing all the limitations imposed by shallow
266 repositories.
267
268 If the source repository is shallow, fetch as much as possible so
269 that the current repository has the same history as the source
270 repository.
271
272 --update-shallow
273 By default when fetching from a shallow repository, git fetch
274 refuses refs that require updating .git/shallow. This option
275 updates .git/shallow and accept such refs.
276
277 --negotiation-tip=<commit|glob>
278 By default, Git will report, to the server, commits reachable from
279 all local refs to find common commits in an attempt to reduce the
280 size of the to-be-received packfile. If specified, Git will only
281 report commits reachable from the given tips. This is useful to
282 speed up fetches when the user knows which local ref is likely to
283 have commits in common with the upstream ref being fetched.
284
285 This option may be specified more than once; if so, Git will report
286 commits reachable from any of the given commits.
287
288 The argument to this option may be a glob on ref names, a ref, or
289 the (possibly abbreviated) SHA-1 of a commit. Specifying a glob is
290 equivalent to specifying this option multiple times, one for each
291 matching ref name.
292
293 See also the fetch.negotiationAlgorithm configuration variable
294 documented in git-config(1).
295
296 -f, --force
297 When git fetch is used with <src>:<dst> refspec it may refuse to
298 update the local branch as discussed in the <refspec> part of the
299 git-fetch(1) documentation. This option overrides that check.
300
301 -k, --keep
302 Keep downloaded pack.
303
304 --no-tags
305 By default, tags that point at objects that are downloaded from the
306 remote repository are fetched and stored locally. This option
307 disables this automatic tag following. The default behavior for a
308 remote may be specified with the remote.<name>.tagOpt setting. See
309 git-config(1).
310
311 -u, --update-head-ok
312 By default git fetch refuses to update the head which corresponds
313 to the current branch. This flag disables the check. This is purely
314 for the internal use for git pull to communicate with git fetch,
315 and unless you are implementing your own Porcelain you are not
316 supposed to use it.
317
318 --upload-pack <upload-pack>
319 When given, and the repository to fetch from is handled by git
320 fetch-pack, --exec=<upload-pack> is passed to the command to
321 specify non-default path for the command run on the other end.
322
323 --progress
324 Progress status is reported on the standard error stream by default
325 when it is attached to a terminal, unless -q is specified. This
326 flag forces progress status even if the standard error stream is
327 not directed to a terminal.
328
329 -o <option>, --server-option=<option>
330 Transmit the given string to the server when communicating using
331 protocol version 2. The given string must not contain a NUL or LF
332 character. When multiple --server-option=<option> are given, they
333 are all sent to the other side in the order listed on the command
334 line.
335
336 -4, --ipv4
337 Use IPv4 addresses only, ignoring IPv6 addresses.
338
339 -6, --ipv6
340 Use IPv6 addresses only, ignoring IPv4 addresses.
341
342 <repository>
343 The "remote" repository that is the source of a fetch or pull
344 operation. This parameter can be either a URL (see the section GIT
345 URLS below) or the name of a remote (see the section REMOTES
346 below).
347
348 <refspec>
349 Specifies which refs to fetch and which local refs to update. When
350 no <refspec>s appear on the command line, the refs to fetch are
351 read from remote.<repository>.fetch variables instead (see git-
352 fetch(1)).
353
354 The format of a <refspec> parameter is an optional plus +, followed
355 by the source <src>, followed by a colon :, followed by the
356 destination ref <dst>. The colon can be omitted when <dst> is
357 empty. <src> is typically a ref, but it can also be a fully spelled
358 hex object name.
359
360 tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; it
361 requests fetching everything up to the given tag.
362
363 The remote ref that matches <src> is fetched, and if <dst> is not
364 an empty string, an attempt is made to update the local ref that
365 matches it.
366
367 Whether that update is allowed without --force depends on the ref
368 namespace it’s being fetched to, the type of object being fetched,
369 and whether the update is considered to be a fast-forward.
370 Generally, the same rules apply for fetching as when pushing, see
371 the <refspec>... section of git-push(1) for what those are.
372 Exceptions to those rules particular to git fetch are noted below.
373
374 Until Git version 2.20, and unlike when pushing with git-push(1),
375 any updates to refs/tags/* would be accepted without + in the
376 refspec (or --force). When fetching, we promiscuously considered
377 all tag updates from a remote to be forced fetches. Since Git
378 version 2.20, fetching to update refs/tags/* works the same way as
379 when pushing. I.e. any updates will be rejected without + in the
380 refspec (or --force).
381
382 Unlike when pushing with git-push(1), any updates outside of
383 refs/{tags,heads}/* will be accepted without + in the refspec (or
384 --force), whether that’s swapping e.g. a tree object for a blob, or
385 a commit for another commit that’s doesn’t have the previous commit
386 as an ancestor etc.
387
388 Unlike when pushing with git-push(1), there is no configuration
389 which’ll amend these rules, and nothing like a pre-fetch hook
390 analogous to the pre-receive hook.
391
392 As with pushing with git-push(1), all of the rules described above
393 about what’s not allowed as an update can be overridden by adding
394 an the optional leading + to a refspec (or using --force command
395 line option). The only exception to this is that no amount of
396 forcing will make the refs/heads/* namespace accept a non-commit
397 object.
398
399 Note
400 When the remote branch you want to fetch is known to be rewound
401 and rebased regularly, it is expected that its new tip will not
402 be descendant of its previous tip (as stored in your
403 remote-tracking branch the last time you fetched). You would
404 want to use the + sign to indicate non-fast-forward updates
405 will be needed for such branches. There is no way to determine
406 or declare that a branch will be made available in a repository
407 with this behavior; the pulling user simply must know this is
408 the expected usage pattern for a branch.
409
410 Note
411 There is a difference between listing multiple <refspec>
412 directly on git pull command line and having multiple
413 remote.<repository>.fetch entries in your configuration for a
414 <repository> and running a git pull command without any
415 explicit <refspec> parameters. <refspec>s listed explicitly on
416 the command line are always merged into the current branch
417 after fetching. In other words, if you list more than one
418 remote ref, git pull will create an Octopus merge. On the other
419 hand, if you do not list any explicit <refspec> parameter on
420 the command line, git pull will fetch all the <refspec>s it
421 finds in the remote.<repository>.fetch configuration and merge
422 only the first <refspec> found into the current branch. This is
423 because making an Octopus from remote refs is rarely done,
424 while keeping track of multiple remote heads in one-go by
425 fetching more than one is often useful.
426
428 In general, URLs contain information about the transport protocol, the
429 address of the remote server, and the path to the repository. Depending
430 on the transport protocol, some of this information may be absent.
431
432 Git supports ssh, git, http, and https protocols (in addition, ftp, and
433 ftps can be used for fetching, but this is inefficient and deprecated;
434 do not use it).
435
436 The native transport (i.e. git:// URL) does no authentication and
437 should be used with caution on unsecured networks.
438
439 The following syntaxes may be used with them:
440
441 · ssh://[user@]host.xz[:port]/path/to/repo.git/
442
443 · git://host.xz[:port]/path/to/repo.git/
444
445 · http[s]://host.xz[:port]/path/to/repo.git/
446
447 · ftp[s]://host.xz[:port]/path/to/repo.git/
448
449 An alternative scp-like syntax may also be used with the ssh protocol:
450
451 · [user@]host.xz:path/to/repo.git/
452
453 This syntax is only recognized if there are no slashes before the first
454 colon. This helps differentiate a local path that contains a colon. For
455 example the local path foo:bar could be specified as an absolute path
456 or ./foo:bar to avoid being misinterpreted as an ssh url.
457
458 The ssh and git protocols additionally support ~username expansion:
459
460 · ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
461
462 · git://host.xz[:port]/~[user]/path/to/repo.git/
463
464 · [user@]host.xz:/~[user]/path/to/repo.git/
465
466 For local repositories, also supported by Git natively, the following
467 syntaxes may be used:
468
469 · /path/to/repo.git/
470
471 · file:///path/to/repo.git/
472
473 These two syntaxes are mostly equivalent, except when cloning, when the
474 former implies --local option. See git-clone(1) for details.
475
476 When Git doesn’t know how to handle a certain transport protocol, it
477 attempts to use the remote-<transport> remote helper, if one exists. To
478 explicitly request a remote helper, the following syntax may be used:
479
480 · <transport>::<address>
481
482 where <address> may be a path, a server and path, or an arbitrary
483 URL-like string recognized by the specific remote helper being invoked.
484 See gitremote-helpers(1) for details.
485
486 If there are a large number of similarly-named remote repositories and
487 you want to use a different format for them (such that the URLs you use
488 will be rewritten into URLs that work), you can create a configuration
489 section of the form:
490
491 [url "<actual url base>"]
492 insteadOf = <other url base>
493
494
495 For example, with this:
496
497 [url "git://git.host.xz/"]
498 insteadOf = host.xz:/path/to/
499 insteadOf = work:
500
501
502 a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
503 rewritten in any context that takes a URL to be
504 "git://git.host.xz/repo.git".
505
506 If you want to rewrite URLs for push only, you can create a
507 configuration section of the form:
508
509 [url "<actual url base>"]
510 pushInsteadOf = <other url base>
511
512
513 For example, with this:
514
515 [url "ssh://example.org/"]
516 pushInsteadOf = git://example.org/
517
518
519 a URL like "git://example.org/path/to/repo.git" will be rewritten to
520 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
521 use the original URL.
522
524 The name of one of the following can be used instead of a URL as
525 <repository> argument:
526
527 · a remote in the Git configuration file: $GIT_DIR/config,
528
529 · a file in the $GIT_DIR/remotes directory, or
530
531 · a file in the $GIT_DIR/branches directory.
532
533 All of these also allow you to omit the refspec from the command line
534 because they each contain a refspec which git will use by default.
535
536 Named remote in configuration file
537 You can choose to provide the name of a remote which you had previously
538 configured using git-remote(1), git-config(1) or even by a manual edit
539 to the $GIT_DIR/config file. The URL of this remote will be used to
540 access the repository. The refspec of this remote will be used by
541 default when you do not provide a refspec on the command line. The
542 entry in the config file would appear like this:
543
544 [remote "<name>"]
545 url = <url>
546 pushurl = <pushurl>
547 push = <refspec>
548 fetch = <refspec>
549
550
551 The <pushurl> is used for pushes only. It is optional and defaults to
552 <url>.
553
554 Named file in $GIT_DIR/remotes
555 You can choose to provide the name of a file in $GIT_DIR/remotes. The
556 URL in this file will be used to access the repository. The refspec in
557 this file will be used as default when you do not provide a refspec on
558 the command line. This file should have the following format:
559
560 URL: one of the above URL format
561 Push: <refspec>
562 Pull: <refspec>
563
564
565 Push: lines are used by git push and Pull: lines are used by git pull
566 and git fetch. Multiple Push: and Pull: lines may be specified for
567 additional branch mappings.
568
569 Named file in $GIT_DIR/branches
570 You can choose to provide the name of a file in $GIT_DIR/branches. The
571 URL in this file will be used to access the repository. This file
572 should have the following format:
573
574 <url>#<head>
575
576
577 <url> is required; #<head> is optional.
578
579 Depending on the operation, git will use one of the following refspecs,
580 if you don’t provide one on the command line. <branch> is the name of
581 this file in $GIT_DIR/branches and <head> defaults to master.
582
583 git fetch uses:
584
585 refs/heads/<head>:refs/heads/<branch>
586
587
588 git push uses:
589
590 HEAD:refs/heads/<head>
591
592
594 The merge mechanism (git merge and git pull commands) allows the
595 backend merge strategies to be chosen with -s option. Some strategies
596 can also take their own options, which can be passed by giving
597 -X<option> arguments to git merge and/or git pull.
598
599 resolve
600 This can only resolve two heads (i.e. the current branch and
601 another branch you pulled from) using a 3-way merge algorithm. It
602 tries to carefully detect criss-cross merge ambiguities and is
603 considered generally safe and fast.
604
605 recursive
606 This can only resolve two heads using a 3-way merge algorithm. When
607 there is more than one common ancestor that can be used for 3-way
608 merge, it creates a merged tree of the common ancestors and uses
609 that as the reference tree for the 3-way merge. This has been
610 reported to result in fewer merge conflicts without causing
611 mismerges by tests done on actual merge commits taken from Linux
612 2.6 kernel development history. Additionally this can detect and
613 handle merges involving renames, but currently cannot make use of
614 detected copies. This is the default merge strategy when pulling or
615 merging one branch.
616
617 The recursive strategy can take the following options:
618
619 ours
620 This option forces conflicting hunks to be auto-resolved
621 cleanly by favoring our version. Changes from the other tree
622 that do not conflict with our side are reflected to the merge
623 result. For a binary file, the entire contents are taken from
624 our side.
625
626 This should not be confused with the ours merge strategy, which
627 does not even look at what the other tree contains at all. It
628 discards everything the other tree did, declaring our history
629 contains all that happened in it.
630
631 theirs
632 This is the opposite of ours; note that, unlike ours, there is
633 no theirs merge strategy to confuse this merge option with.
634
635 patience
636 With this option, merge-recursive spends a little extra time to
637 avoid mismerges that sometimes occur due to unimportant
638 matching lines (e.g., braces from distinct functions). Use this
639 when the branches to be merged have diverged wildly. See also
640 git-diff(1) --patience.
641
642 diff-algorithm=[patience|minimal|histogram|myers]
643 Tells merge-recursive to use a different diff algorithm, which
644 can help avoid mismerges that occur due to unimportant matching
645 lines (such as braces from distinct functions). See also git-
646 diff(1) --diff-algorithm.
647
648 ignore-space-change, ignore-all-space, ignore-space-at-eol,
649 ignore-cr-at-eol
650 Treats lines with the indicated type of whitespace change as
651 unchanged for the sake of a three-way merge. Whitespace changes
652 mixed with other changes to a line are not ignored. See also
653 git-diff(1) -b, -w, --ignore-space-at-eol, and
654 --ignore-cr-at-eol.
655
656 · If their version only introduces whitespace changes to a
657 line, our version is used;
658
659 · If our version introduces whitespace changes but their
660 version includes a substantial change, their version is
661 used;
662
663 · Otherwise, the merge proceeds in the usual way.
664
665 renormalize
666 This runs a virtual check-out and check-in of all three stages
667 of a file when resolving a three-way merge. This option is
668 meant to be used when merging branches with different clean
669 filters or end-of-line normalization rules. See "Merging
670 branches with differing checkin/checkout attributes" in
671 gitattributes(5) for details.
672
673 no-renormalize
674 Disables the renormalize option. This overrides the
675 merge.renormalize configuration variable.
676
677 no-renames
678 Turn off rename detection. This overrides the merge.renames
679 configuration variable. See also git-diff(1) --no-renames.
680
681 find-renames[=<n>]
682 Turn on rename detection, optionally setting the similarity
683 threshold. This is the default. This overrides the
684 merge.renames configuration variable. See also git-diff(1)
685 --find-renames.
686
687 rename-threshold=<n>
688 Deprecated synonym for find-renames=<n>.
689
690 subtree[=<path>]
691 This option is a more advanced form of subtree strategy, where
692 the strategy makes a guess on how two trees must be shifted to
693 match with each other when merging. Instead, the specified path
694 is prefixed (or stripped from the beginning) to make the shape
695 of two trees to match.
696
697 octopus
698 This resolves cases with more than two heads, but refuses to do a
699 complex merge that needs manual resolution. It is primarily meant
700 to be used for bundling topic branch heads together. This is the
701 default merge strategy when pulling or merging more than one
702 branch.
703
704 ours
705 This resolves any number of heads, but the resulting tree of the
706 merge is always that of the current branch head, effectively
707 ignoring all changes from all other branches. It is meant to be
708 used to supersede old development history of side branches. Note
709 that this is different from the -Xours option to the recursive
710 merge strategy.
711
712 subtree
713 This is a modified recursive strategy. When merging trees A and B,
714 if B corresponds to a subtree of A, B is first adjusted to match
715 the tree structure of A, instead of reading the trees at the same
716 level. This adjustment is also done to the common ancestor tree.
717
718 With the strategies that use 3-way merge (including the default,
719 recursive), if a change is made on both branches, but later reverted on
720 one of the branches, that change will be present in the merged result;
721 some people find this behavior confusing. It occurs because only the
722 heads and the merge base are considered when performing a merge, not
723 the individual commits. The merge algorithm therefore considers the
724 reverted change as no change at all, and substitutes the changed
725 version instead.
726
728 Often people use git pull without giving any parameter. Traditionally,
729 this has been equivalent to saying git pull origin. However, when
730 configuration branch.<name>.remote is present while on branch <name>,
731 that value is used instead of origin.
732
733 In order to determine what URL to use to fetch from, the value of the
734 configuration remote.<origin>.url is consulted and if there is not any
735 such variable, the value on the URL: line in $GIT_DIR/remotes/<origin>
736 is used.
737
738 In order to determine what remote branches to fetch (and optionally
739 store in the remote-tracking branches) when the command is run without
740 any refspec parameters on the command line, values of the configuration
741 variable remote.<origin>.fetch are consulted, and if there aren’t any,
742 $GIT_DIR/remotes/<origin> is consulted and its Pull: lines are used. In
743 addition to the refspec formats described in the OPTIONS section, you
744 can have a globbing refspec that looks like this:
745
746 refs/heads/*:refs/remotes/origin/*
747
748
749 A globbing refspec must have a non-empty RHS (i.e. must store what were
750 fetched in remote-tracking branches), and its LHS and RHS must end with
751 /*. The above specifies that all remote branches are tracked using
752 remote-tracking branches in refs/remotes/origin/ hierarchy under the
753 same name.
754
755 The rule to determine which remote branch to merge after fetching is a
756 bit involved, in order not to break backward compatibility.
757
758 If explicit refspecs were given on the command line of git pull, they
759 are all merged.
760
761 When no refspec was given on the command line, then git pull uses the
762 refspec from the configuration or $GIT_DIR/remotes/<origin>. In such
763 cases, the following rules apply:
764
765 1. If branch.<name>.merge configuration for the current branch <name>
766 exists, that is the name of the branch at the remote site that is
767 merged.
768
769 2. If the refspec is a globbing one, nothing is merged.
770
771 3. Otherwise the remote branch of the first refspec is merged.
772
774 · Update the remote-tracking branches for the repository you cloned
775 from, then merge one of them into your current branch:
776
777 $ git pull
778 $ git pull origin
779
780 Normally the branch merged in is the HEAD of the remote repository,
781 but the choice is determined by the branch.<name>.remote and
782 branch.<name>.merge options; see git-config(1) for details.
783
784 · Merge into the current branch the remote branch next:
785
786 $ git pull origin next
787
788 This leaves a copy of next temporarily in FETCH_HEAD, but does not
789 update any remote-tracking branches. Using remote-tracking
790 branches, the same can be done by invoking fetch and merge:
791
792 $ git fetch origin
793 $ git merge origin/next
794
795
796 If you tried a pull which resulted in complex conflicts and would want
797 to start over, you can recover with git reset.
798
800 The fetch and push protocols are not designed to prevent one side from
801 stealing data from the other repository that was not intended to be
802 shared. If you have private data that you need to protect from a
803 malicious peer, your best option is to store it in another repository.
804 This applies to both clients and servers. In particular, namespaces on
805 a server are not effective for read access control; you should only
806 grant read access to a namespace to clients that you would trust with
807 read access to the entire repository.
808
809 The known attack vectors are as follows:
810
811 1. The victim sends "have" lines advertising the IDs of objects it has
812 that are not explicitly intended to be shared but can be used to
813 optimize the transfer if the peer also has them. The attacker
814 chooses an object ID X to steal and sends a ref to X, but isn’t
815 required to send the content of X because the victim already has
816 it. Now the victim believes that the attacker has X, and it sends
817 the content of X back to the attacker later. (This attack is most
818 straightforward for a client to perform on a server, by creating a
819 ref to X in the namespace the client has access to and then
820 fetching it. The most likely way for a server to perform it on a
821 client is to "merge" X into a public branch and hope that the user
822 does additional work on this branch and pushes it back to the
823 server without noticing the merge.)
824
825 2. As in #1, the attacker chooses an object ID X to steal. The victim
826 sends an object Y that the attacker already has, and the attacker
827 falsely claims to have X and not Y, so the victim sends Y as a
828 delta against X. The delta reveals regions of X that are similar to
829 Y to the attacker.
830
832 Using --recurse-submodules can only fetch new commits in already
833 checked out submodules right now. When e.g. upstream added a new
834 submodule in the just fetched commits of the superproject the submodule
835 itself can not be fetched, making it impossible to check out that
836 submodule later without having to do a fetch again. This is expected to
837 be fixed in a future Git version.
838
840 git-fetch(1), git-merge(1), git-config(1)
841
843 Part of the git(1) suite
844
845
846
847Git 2.21.0 02/24/2019 GIT-PULL(1)