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

NAME

6       git-pull - Fetch from and integrate with another repository or a local
7       branch
8

SYNOPSIS

10       git pull [<options>] [<repository> [<refspec>...]]
11

DESCRIPTION

13       Incorporates changes from a remote repository into the current branch.
14       If the current branch is behind the remote, then by default it will
15       fast-forward the current branch to match the remote. If the current
16       branch and the remote have diverged, the user needs to specify how to
17       reconcile the divergent branches with --rebase or --no-rebase (or the
18       corresponding configuration option in pull.rebase).
19
20       More precisely, git pull runs git fetch with the given parameters and
21       then depending on configuration options or command line flags, will
22       call either git rebase or git merge to reconcile diverging branches.
23
24       <repository> should be the name of a remote repository as passed to
25       git-fetch(1). <refspec> can name an arbitrary remote ref (for example,
26       the name of a tag) or even a collection of refs with corresponding
27       remote-tracking branches (e.g., refs/heads/*:refs/remotes/origin/*),
28       but usually it is the name of a branch in the remote repository.
29
30       Default values for <repository> and <branch> are read from the "remote"
31       and "merge" configuration for the current branch as set by git-
32       branch(1) --track.
33
34       Assume the following history exists and the current branch is "master":
35
36                     A---B---C master on origin
37                    /
38               D---E---F---G master
39                   ^
40                   origin/master in your repository
41
42       Then "git pull" will fetch and replay the changes from the remote
43       master branch since it diverged from the local master (i.e., E) until
44       its current commit (C) on top of master and record the result in a new
45       commit along with the names of the two parent commits and a log message
46       from the user describing the changes.
47
48                     A---B---C origin/master
49                    /         \
50               D---E---F---G---H master
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

OPTIONS

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 populated submodules should
76           be fetched, and if the working trees of active submodules should be
77           updated, too (see git-fetch(1), git-config(1) and 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. Only useful when merging.
89
90           With --no-commit perform the merge and stop just before creating a
91           merge commit, to give the user a chance to inspect and further
92           tweak the merge result before committing.
93
94           Note that fast-forward updates do not create a merge commit and
95           therefore there is no way to stop those merges with --no-commit.
96           Thus, if you want to ensure your branch is not changed or updated
97           by the merge command, use --no-ff with --no-commit.
98
99       --edit, -e, --no-edit
100           Invoke an editor before committing successful mechanical merge to
101           further edit the auto-generated merge message, so that the user can
102           explain and justify the merge. The --no-edit option can be used to
103           accept the auto-generated message (this is generally discouraged).
104
105           Older scripts may depend on the historical behaviour of not
106           allowing the user to edit the merge log message. They will see an
107           editor opened when they run git merge. To make it easier to adjust
108           such scripts to the updated behaviour, the environment variable
109           GIT_MERGE_AUTOEDIT can be set to no at the beginning of them.
110
111       --cleanup=<mode>
112           This option determines how the merge message will be cleaned up
113           before committing. See git-commit(1) for more details. In addition,
114           if the <mode> is given a value of scissors, scissors will be
115           appended to MERGE_MSG before being passed on to the commit
116           machinery in the case of a merge conflict.
117
118       --ff-only
119           Only update to the new history if there is no divergent local
120           history. This is the default when no method for reconciling
121           divergent histories is provided (via the --rebase=* flags).
122
123       --ff, --no-ff
124           When merging rather than rebasing, specifies how a merge is handled
125           when the merged-in history is already a descendant of the current
126           history. If merging is requested, --ff is the default unless
127           merging an annotated (and possibly signed) tag that is not stored
128           in its natural place in the refs/tags/ hierarchy, in which case
129           --no-ff is assumed.
130
131           With --ff, when possible resolve the merge as a fast-forward (only
132           update the branch pointer to match the merged branch; do not create
133           a merge commit). When not possible (when the merged-in history is
134           not a descendant of the current history), create a merge commit.
135
136           With --no-ff, create a merge commit in all cases, even when the
137           merge could instead be resolved as a fast-forward.
138
139       -S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign
140           GPG-sign the resulting merge commit. The keyid argument is optional
141           and defaults to the committer identity; if specified, it must be
142           stuck to the option without a space.  --no-gpg-sign is useful to
143           countermand both commit.gpgSign configuration variable, and earlier
144           --gpg-sign.
145
146       --log[=<n>], --no-log
147           In addition to branch names, populate the log message with one-line
148           descriptions from at most <n> actual commits that are being merged.
149           See also git-fmt-merge-msg(1). Only useful when merging.
150
151           With --no-log do not list one-line descriptions from the actual
152           commits being merged.
153
154       --signoff, --no-signoff
155           Add a Signed-off-by trailer by the committer at the end of the
156           commit log message. The meaning of a signoff depends on the project
157           to which you’re committing. For example, it may certify that the
158           committer has the rights to submit the work under the project’s
159           license or agrees to some contributor representation, such as a
160           Developer Certificate of Origin. (See
161           http://developercertificate.org for the one used by the Linux
162           kernel and Git projects.) Consult the documentation or leadership
163           of the project to which you’re contributing to understand how the
164           signoffs are used in that project.
165
166           The --no-signoff option can be used to countermand an earlier
167           --signoff option on the command line.
168
169       --stat, -n, --no-stat
170           Show a diffstat at the end of the merge. The diffstat is also
171           controlled by the configuration option merge.stat.
172
173           With -n or --no-stat do not show a diffstat at the end of the
174           merge.
175
176       --squash, --no-squash
177           Produce the working tree and index state as if a real merge
178           happened (except for the merge information), but do not actually
179           make a commit, move the HEAD, or record $GIT_DIR/MERGE_HEAD (to
180           cause the next git commit command to create a merge commit). This
181           allows you to create a single commit on top of the current branch
182           whose effect is the same as merging another branch (or more in case
183           of an octopus).
184
185           With --no-squash perform the merge and commit the result. This
186           option can be used to override --squash.
187
188           With --squash, --commit is not allowed, and will fail.
189
190           Only useful when merging.
191
192       --[no-]verify
193           By default, the pre-merge and commit-msg hooks are run. When
194           --no-verify is given, these are bypassed. See also githooks(5).
195           Only useful when merging.
196
197       -s <strategy>, --strategy=<strategy>
198           Use the given merge strategy; can be supplied more than once to
199           specify them in the order they should be tried. If there is no -s
200           option, a built-in list of strategies is used instead (ort when
201           merging a single head, octopus otherwise).
202
203       -X <option>, --strategy-option=<option>
204           Pass merge strategy specific option through to the merge strategy.
205
206       --verify-signatures, --no-verify-signatures
207           Verify that the tip commit of the side branch being merged is
208           signed with a valid key, i.e. a key that has a valid uid: in the
209           default trust model, this means the signing key has been signed by
210           a trusted key. If the tip commit of the side branch is not signed
211           with a valid key, the merge is aborted.
212
213           Only useful when merging.
214
215       --summary, --no-summary
216           Synonyms to --stat and --no-stat; these are deprecated and will be
217           removed in the future.
218
219       --autostash, --no-autostash
220           Automatically create a temporary stash entry before the operation
221           begins, record it in the special ref MERGE_AUTOSTASH and apply it
222           after the operation ends. This means that you can run the operation
223           on a dirty worktree. However, use with care: the final stash
224           application after a successful merge might result in non-trivial
225           conflicts.
226
227       --allow-unrelated-histories
228           By default, git merge command refuses to merge histories that do
229           not share a common ancestor. This option can be used to override
230           this safety when merging histories of two projects that started
231           their lives independently. As that is a very rare occasion, no
232           configuration variable to enable this by default exists and will
233           not be added.
234
235           Only useful when merging.
236
237       -r, --rebase[=false|true|merges|interactive]
238           When true, rebase the current branch on top of the upstream branch
239           after fetching. If there is a remote-tracking branch corresponding
240           to the upstream branch and the upstream branch was rebased since
241           last fetched, the rebase uses that information to avoid rebasing
242           non-local changes.
243
244           When set to merges, rebase using git rebase --rebase-merges so that
245           the local merge commits are included in the rebase (see git-
246           rebase(1) for details).
247
248           When false, merge the upstream branch into the current branch.
249
250           When interactive, enable the interactive mode of rebase.
251
252           See pull.rebase, branch.<name>.rebase and branch.autoSetupRebase in
253           git-config(1) if you want to make git pull always use --rebase
254           instead of merging.
255
256               Note
257               This is a potentially dangerous mode of operation. It rewrites
258               history, which does not bode well when you published that
259               history already. Do not use this option unless you have read
260               git-rebase(1) carefully.
261
262       --no-rebase
263           This is shorthand for --rebase=false.
264
265   Options related to fetching
266       --all
267           Fetch all remotes.
268
269       -a, --append
270           Append ref names and object names of fetched refs to the existing
271           contents of .git/FETCH_HEAD. Without this option old data in
272           .git/FETCH_HEAD will be overwritten.
273
274       --atomic
275           Use an atomic transaction to update local refs. Either all refs are
276           updated, or on error, no refs are updated.
277
278       --depth=<depth>
279           Limit fetching to the specified number of commits from the tip of
280           each remote branch history. If fetching to a shallow repository
281           created by git clone with --depth=<depth> option (see git-
282           clone(1)), deepen or shorten the history to the specified number of
283           commits. Tags for the deepened commits are not fetched.
284
285       --deepen=<depth>
286           Similar to --depth, except it specifies the number of commits from
287           the current shallow boundary instead of from the tip of each remote
288           branch history.
289
290       --shallow-since=<date>
291           Deepen or shorten the history of a shallow repository to include
292           all reachable commits after <date>.
293
294       --shallow-exclude=<revision>
295           Deepen or shorten the history of a shallow repository to exclude
296           commits reachable from a specified remote branch or tag. This
297           option can be specified multiple times.
298
299       --unshallow
300           If the source repository is complete, convert a shallow repository
301           to a complete one, removing all the limitations imposed by shallow
302           repositories.
303
304           If the source repository is shallow, fetch as much as possible so
305           that the current repository has the same history as the source
306           repository.
307
308       --update-shallow
309           By default when fetching from a shallow repository, git fetch
310           refuses refs that require updating .git/shallow. This option
311           updates .git/shallow and accepts such refs.
312
313       --negotiation-tip=<commit|glob>
314           By default, Git will report, to the server, commits reachable from
315           all local refs to find common commits in an attempt to reduce the
316           size of the to-be-received packfile. If specified, Git will only
317           report commits reachable from the given tips. This is useful to
318           speed up fetches when the user knows which local ref is likely to
319           have commits in common with the upstream ref being fetched.
320
321           This option may be specified more than once; if so, Git will report
322           commits reachable from any of the given commits.
323
324           The argument to this option may be a glob on ref names, a ref, or
325           the (possibly abbreviated) SHA-1 of a commit. Specifying a glob is
326           equivalent to specifying this option multiple times, one for each
327           matching ref name.
328
329           See also the fetch.negotiationAlgorithm and push.negotiate
330           configuration variables documented in git-config(1), and the
331           --negotiate-only option below.
332
333       --negotiate-only
334           Do not fetch anything from the server, and instead print the
335           ancestors of the provided --negotiation-tip=* arguments, which we
336           have in common with the server.
337
338           This is incompatible with --recurse-submodules=[yes|on-demand].
339           Internally this is used to implement the push.negotiate option, see
340           git-config(1).
341
342       --dry-run
343           Show what would be done, without making any changes.
344
345       --porcelain
346           Print the output to standard output in an easy-to-parse format for
347           scripts. See section OUTPUT in git-fetch(1) for details.
348
349           This is incompatible with --recurse-submodules=[yes|on-demand] and
350           takes precedence over the fetch.output config option.
351
352       -f, --force
353           When git fetch is used with <src>:<dst> refspec, it may refuse to
354           update the local branch as discussed in the <refspec> part of the
355           git-fetch(1) documentation. This option overrides that check.
356
357       -k, --keep
358           Keep downloaded pack.
359
360       --prefetch
361           Modify the configured refspec to place all refs into the
362           refs/prefetch/ namespace. See the prefetch task in git-
363           maintenance(1).
364
365       -p, --prune
366           Before fetching, remove any remote-tracking references that no
367           longer exist on the remote. Tags are not subject to pruning if they
368           are fetched only because of the default tag auto-following or due
369           to a --tags option. However, if tags are fetched due to an explicit
370           refspec (either on the command line or in the remote configuration,
371           for example if the remote was cloned with the --mirror option),
372           then they are also subject to pruning. Supplying --prune-tags is a
373           shorthand for providing the tag refspec.
374
375       --no-tags
376           By default, tags that point at objects that are downloaded from the
377           remote repository are fetched and stored locally. This option
378           disables this automatic tag following. The default behavior for a
379           remote may be specified with the remote.<name>.tagOpt setting. See
380           git-config(1).
381
382       --refmap=<refspec>
383           When fetching refs listed on the command line, use the specified
384           refspec (can be given more than once) to map the refs to
385           remote-tracking branches, instead of the values of remote.*.fetch
386           configuration variables for the remote repository. Providing an
387           empty <refspec> to the --refmap option causes Git to ignore the
388           configured refspecs and rely entirely on the refspecs supplied as
389           command-line arguments. See section on "Configured Remote-tracking
390           Branches" for details.
391
392       -t, --tags
393           Fetch all tags from the remote (i.e., fetch remote tags refs/tags/*
394           into local tags with the same name), in addition to whatever else
395           would otherwise be fetched. Using this option alone does not
396           subject tags to pruning, even if --prune is used (though tags may
397           be pruned anyway if they are also the destination of an explicit
398           refspec; see --prune).
399
400       -j, --jobs=<n>
401           Number of parallel children to be used for all forms of fetching.
402
403           If the --multiple option was specified, the different remotes will
404           be fetched in parallel. If multiple submodules are fetched, they
405           will be fetched in parallel. To control them independently, use the
406           config settings fetch.parallel and submodule.fetchJobs (see git-
407           config(1)).
408
409           Typically, parallel recursive and multi-remote fetches will be
410           faster. By default fetches are performed sequentially, not in
411           parallel.
412
413       --set-upstream
414           If the remote is fetched successfully, add upstream (tracking)
415           reference, used by argument-less git-pull(1) and other commands.
416           For more information, see branch.<name>.merge and
417           branch.<name>.remote in git-config(1).
418
419       --upload-pack <upload-pack>
420           When given, and the repository to fetch from is handled by git
421           fetch-pack, --exec=<upload-pack> is passed to the command to
422           specify non-default path for the command run on the other end.
423
424       --progress
425           Progress status is reported on the standard error stream by default
426           when it is attached to a terminal, unless -q is specified. This
427           flag forces progress status even if the standard error stream is
428           not directed to a terminal.
429
430       -o <option>, --server-option=<option>
431           Transmit the given string to the server when communicating using
432           protocol version 2. The given string must not contain a NUL or LF
433           character. The server’s handling of server options, including
434           unknown ones, is server-specific. When multiple
435           --server-option=<option> are given, they are all sent to the other
436           side in the order listed on the command line.
437
438       --show-forced-updates
439           By default, git checks if a branch is force-updated during fetch.
440           This can be disabled through fetch.showForcedUpdates, but the
441           --show-forced-updates option guarantees this check occurs. See git-
442           config(1).
443
444       --no-show-forced-updates
445           By default, git checks if a branch is force-updated during fetch.
446           Pass --no-show-forced-updates or set fetch.showForcedUpdates to
447           false to skip this check for performance reasons. If used during
448           git-pull the --ff-only option will still check for forced updates
449           before attempting a fast-forward update. See git-config(1).
450
451       -4, --ipv4
452           Use IPv4 addresses only, ignoring IPv6 addresses.
453
454       -6, --ipv6
455           Use IPv6 addresses only, ignoring IPv4 addresses.
456
457       <repository>
458           The "remote" repository that is the source of a fetch or pull
459           operation. This parameter can be either a URL (see the section GIT
460           URLS below) or the name of a remote (see the section REMOTES
461           below).
462
463       <refspec>
464           Specifies which refs to fetch and which local refs to update. When
465           no <refspec>s appear on the command line, the refs to fetch are
466           read from remote.<repository>.fetch variables instead (see the
467           section "CONFIGURED REMOTE-TRACKING BRANCHES" in git-fetch(1)).
468
469           The format of a <refspec> parameter is an optional plus +, followed
470           by the source <src>, followed by a colon :, followed by the
471           destination ref <dst>. The colon can be omitted when <dst> is
472           empty. <src> is typically a ref, but it can also be a fully spelled
473           hex object name.
474
475           A <refspec> may contain a * in its <src> to indicate a simple
476           pattern match. Such a refspec functions like a glob that matches
477           any ref with the same prefix. A pattern <refspec> must have a * in
478           both the <src> and <dst>. It will map refs to the destination by
479           replacing the * with the contents matched from the source.
480
481           If a refspec is prefixed by ^, it will be interpreted as a negative
482           refspec. Rather than specifying which refs to fetch or which local
483           refs to update, such a refspec will instead specify refs to
484           exclude. A ref will be considered to match if it matches at least
485           one positive refspec, and does not match any negative refspec.
486           Negative refspecs can be useful to restrict the scope of a pattern
487           refspec so that it will not include specific refs. Negative
488           refspecs can themselves be pattern refspecs. However, they may only
489           contain a <src> and do not specify a <dst>. Fully spelled out hex
490           object names are also not supported.
491
492           tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>; it
493           requests fetching everything up to the given tag.
494
495           The remote ref that matches <src> is fetched, and if <dst> is not
496           an empty string, an attempt is made to update the local ref that
497           matches it.
498
499           Whether that update is allowed without --force depends on the ref
500           namespace it’s being fetched to, the type of object being fetched,
501           and whether the update is considered to be a fast-forward.
502           Generally, the same rules apply for fetching as when pushing, see
503           the <refspec>...  section of git-push(1) for what those are.
504           Exceptions to those rules particular to git fetch are noted below.
505
506           Until Git version 2.20, and unlike when pushing with git-push(1),
507           any updates to refs/tags/* would be accepted without + in the
508           refspec (or --force). When fetching, we promiscuously considered
509           all tag updates from a remote to be forced fetches. Since Git
510           version 2.20, fetching to update refs/tags/* works the same way as
511           when pushing. I.e. any updates will be rejected without + in the
512           refspec (or --force).
513
514           Unlike when pushing with git-push(1), any updates outside of
515           refs/{tags,heads}/* will be accepted without + in the refspec (or
516           --force), whether that’s swapping e.g. a tree object for a blob, or
517           a commit for another commit that doesn’t have the previous commit
518           as an ancestor etc.
519
520           Unlike when pushing with git-push(1), there is no configuration
521           which’ll amend these rules, and nothing like a pre-fetch hook
522           analogous to the pre-receive hook.
523
524           As with pushing with git-push(1), all of the rules described above
525           about what’s not allowed as an update can be overridden by adding
526           an optional leading + to a refspec (or using the --force command
527           line option). The only exception to this is that no amount of
528           forcing will make the refs/heads/* namespace accept a non-commit
529           object.
530
531               Note
532               When the remote branch you want to fetch is known to be rewound
533               and rebased regularly, it is expected that its new tip will not
534               be a descendant of its previous tip (as stored in your
535               remote-tracking branch the last time you fetched). You would
536               want to use the + sign to indicate non-fast-forward updates
537               will be needed for such branches. There is no way to determine
538               or declare that a branch will be made available in a repository
539               with this behavior; the pulling user simply must know this is
540               the expected usage pattern for a branch.
541
542               Note
543               There is a difference between listing multiple <refspec>
544               directly on git pull command line and having multiple
545               remote.<repository>.fetch entries in your configuration for a
546               <repository> and running a git pull command without any
547               explicit <refspec> parameters. <refspec>s listed explicitly on
548               the command line are always merged into the current branch
549               after fetching. In other words, if you list more than one
550               remote ref, git pull will create an Octopus merge. On the other
551               hand, if you do not list any explicit <refspec> parameter on
552               the command line, git pull will fetch all the <refspec>s it
553               finds in the remote.<repository>.fetch configuration and merge
554               only the first <refspec> found into the current branch. This is
555               because making an Octopus from remote refs is rarely done,
556               while keeping track of multiple remote heads in one-go by
557               fetching more than one is often useful.
558

GIT URLS

560       In general, URLs contain information about the transport protocol, the
561       address of the remote server, and the path to the repository. Depending
562       on the transport protocol, some of this information may be absent.
563
564       Git supports ssh, git, http, and https protocols (in addition, ftp and
565       ftps can be used for fetching, but this is inefficient and deprecated;
566       do not use them).
567
568       The native transport (i.e. git:// URL) does no authentication and
569       should be used with caution on unsecured networks.
570
571       The following syntaxes may be used with them:
572
573       •   ssh://[user@]host.xz[:port]/path/to/repo.git/
574
575       •   git://host.xz[:port]/path/to/repo.git/
576
577       •   http[s]://host.xz[:port]/path/to/repo.git/
578
579       •   ftp[s]://host.xz[:port]/path/to/repo.git/
580
581       An alternative scp-like syntax may also be used with the ssh protocol:
582
583       •   [user@]host.xz:path/to/repo.git/
584
585       This syntax is only recognized if there are no slashes before the first
586       colon. This helps differentiate a local path that contains a colon. For
587       example the local path foo:bar could be specified as an absolute path
588       or ./foo:bar to avoid being misinterpreted as an ssh url.
589
590       The ssh and git protocols additionally support ~username expansion:
591
592       •   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
593
594       •   git://host.xz[:port]/~[user]/path/to/repo.git/
595
596       •   [user@]host.xz:/~[user]/path/to/repo.git/
597
598       For local repositories, also supported by Git natively, the following
599       syntaxes may be used:
600
601       •   /path/to/repo.git/
602
603       •   file:///path/to/repo.git/
604
605       These two syntaxes are mostly equivalent, except when cloning, when the
606       former implies --local option. See git-clone(1) for details.
607
608       git clone, git fetch and git pull, but not git push, will also accept a
609       suitable bundle file. See git-bundle(1).
610
611       When Git doesn’t know how to handle a certain transport protocol, it
612       attempts to use the remote-<transport> remote helper, if one exists. To
613       explicitly request a remote helper, the following syntax may be used:
614
615       •   <transport>::<address>
616
617       where <address> may be a path, a server and path, or an arbitrary
618       URL-like string recognized by the specific remote helper being invoked.
619       See gitremote-helpers(7) for details.
620
621       If there are a large number of similarly-named remote repositories and
622       you want to use a different format for them (such that the URLs you use
623       will be rewritten into URLs that work), you can create a configuration
624       section of the form:
625
626                   [url "<actual url base>"]
627                           insteadOf = <other url base>
628
629       For example, with this:
630
631                   [url "git://git.host.xz/"]
632                           insteadOf = host.xz:/path/to/
633                           insteadOf = work:
634
635       a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
636       rewritten in any context that takes a URL to be
637       "git://git.host.xz/repo.git".
638
639       If you want to rewrite URLs for push only, you can create a
640       configuration section of the form:
641
642                   [url "<actual url base>"]
643                           pushInsteadOf = <other url base>
644
645       For example, with this:
646
647                   [url "ssh://example.org/"]
648                           pushInsteadOf = git://example.org/
649
650       a URL like "git://example.org/path/to/repo.git" will be rewritten to
651       "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
652       use the original URL.
653

REMOTES

655       The name of one of the following can be used instead of a URL as
656       <repository> argument:
657
658       •   a remote in the Git configuration file: $GIT_DIR/config,
659
660       •   a file in the $GIT_DIR/remotes directory, or
661
662       •   a file in the $GIT_DIR/branches directory.
663
664       All of these also allow you to omit the refspec from the command line
665       because they each contain a refspec which git will use by default.
666
667   Named remote in configuration file
668       You can choose to provide the name of a remote which you had previously
669       configured using git-remote(1), git-config(1) or even by a manual edit
670       to the $GIT_DIR/config file. The URL of this remote will be used to
671       access the repository. The refspec of this remote will be used by
672       default when you do not provide a refspec on the command line. The
673       entry in the config file would appear like this:
674
675                   [remote "<name>"]
676                           url = <URL>
677                           pushurl = <pushurl>
678                           push = <refspec>
679                           fetch = <refspec>
680
681       The <pushurl> is used for pushes only. It is optional and defaults to
682       <URL>. Pushing to a remote affects all defined pushurls or all defined
683       urls if no pushurls are defined. Fetch, however, will only fetch from
684       the first defined url if multiple urls are defined.
685
686   Named file in $GIT_DIR/remotes
687       You can choose to provide the name of a file in $GIT_DIR/remotes. The
688       URL in this file will be used to access the repository. The refspec in
689       this file will be used as default when you do not provide a refspec on
690       the command line. This file should have the following format:
691
692                   URL: one of the above URL formats
693                   Push: <refspec>
694                   Pull: <refspec>
695
696       Push: lines are used by git push and Pull: lines are used by git pull
697       and git fetch. Multiple Push: and Pull: lines may be specified for
698       additional branch mappings.
699
700   Named file in $GIT_DIR/branches
701       You can choose to provide the name of a file in $GIT_DIR/branches. The
702       URL in this file will be used to access the repository. This file
703       should have the following format:
704
705                   <URL>#<head>
706
707       <URL> is required; #<head> is optional.
708
709       Depending on the operation, git will use one of the following refspecs,
710       if you don’t provide one on the command line. <branch> is the name of
711       this file in $GIT_DIR/branches and <head> defaults to master.
712
713       git fetch uses:
714
715                   refs/heads/<head>:refs/heads/<branch>
716
717       git push uses:
718
719                   HEAD:refs/heads/<head>
720

MERGE STRATEGIES

722       The merge mechanism (git merge and git pull commands) allows the
723       backend merge strategies to be chosen with -s option. Some strategies
724       can also take their own options, which can be passed by giving
725       -X<option> arguments to git merge and/or git pull.
726
727       ort
728           This is the default merge strategy when pulling or merging one
729           branch. This strategy can only resolve two heads using a 3-way
730           merge algorithm. When there is more than one common ancestor that
731           can be used for 3-way merge, it creates a merged tree of the common
732           ancestors and uses that as the reference tree for the 3-way merge.
733           This has been reported to result in fewer merge conflicts without
734           causing mismerges by tests done on actual merge commits taken from
735           Linux 2.6 kernel development history. Additionally this strategy
736           can detect and handle merges involving renames. It does not make
737           use of detected copies. The name for this algorithm is an acronym
738           ("Ostensibly Recursive’s Twin") and came from the fact that it was
739           written as a replacement for the previous default algorithm,
740           recursive.
741
742           The ort strategy can take the following options:
743
744           ours
745               This option forces conflicting hunks to be auto-resolved
746               cleanly by favoring our version. Changes from the other tree
747               that do not conflict with our side are reflected in the merge
748               result. For a binary file, the entire contents are taken from
749               our side.
750
751               This should not be confused with the ours merge strategy, which
752               does not even look at what the other tree contains at all. It
753               discards everything the other tree did, declaring our history
754               contains all that happened in it.
755
756           theirs
757               This is the opposite of ours; note that, unlike ours, there is
758               no theirs merge strategy to confuse this merge option with.
759
760           ignore-space-change, ignore-all-space, ignore-space-at-eol,
761           ignore-cr-at-eol
762               Treats lines with the indicated type of whitespace change as
763               unchanged for the sake of a three-way merge. Whitespace changes
764               mixed with other changes to a line are not ignored. See also
765               git-diff(1) -b, -w, --ignore-space-at-eol, and
766               --ignore-cr-at-eol.
767
768               •   If their version only introduces whitespace changes to a
769                   line, our version is used;
770
771               •   If our version introduces whitespace changes but their
772                   version includes a substantial change, their version is
773                   used;
774
775               •   Otherwise, the merge proceeds in the usual way.
776
777           renormalize
778               This runs a virtual check-out and check-in of all three stages
779               of a file when resolving a three-way merge. This option is
780               meant to be used when merging branches with different clean
781               filters or end-of-line normalization rules. See "Merging
782               branches with differing checkin/checkout attributes" in
783               gitattributes(5) for details.
784
785           no-renormalize
786               Disables the renormalize option. This overrides the
787               merge.renormalize configuration variable.
788
789           find-renames[=<n>]
790               Turn on rename detection, optionally setting the similarity
791               threshold. This is the default. This overrides the
792               merge.renames configuration variable. See also git-diff(1)
793               --find-renames.
794
795           rename-threshold=<n>
796               Deprecated synonym for find-renames=<n>.
797
798           subtree[=<path>]
799               This option is a more advanced form of subtree strategy, where
800               the strategy makes a guess on how two trees must be shifted to
801               match with each other when merging. Instead, the specified path
802               is prefixed (or stripped from the beginning) to make the shape
803               of two trees to match.
804
805       recursive
806           This can only resolve two heads using a 3-way merge algorithm. When
807           there is more than one common ancestor that can be used for 3-way
808           merge, it creates a merged tree of the common ancestors and uses
809           that as the reference tree for the 3-way merge. This has been
810           reported to result in fewer merge conflicts without causing
811           mismerges by tests done on actual merge commits taken from Linux
812           2.6 kernel development history. Additionally this can detect and
813           handle merges involving renames. It does not make use of detected
814           copies. This was the default strategy for resolving two heads from
815           Git v0.99.9k until v2.33.0.
816
817           The recursive strategy takes the same options as ort. However,
818           there are three additional options that ort ignores (not documented
819           above) that are potentially useful with the recursive strategy:
820
821           patience
822               Deprecated synonym for diff-algorithm=patience.
823
824           diff-algorithm=[patience|minimal|histogram|myers]
825               Use a different diff algorithm while merging, which can help
826               avoid mismerges that occur due to unimportant matching lines
827               (such as braces from distinct functions). See also git-diff(1)
828               --diff-algorithm. Note that ort specifically uses
829               diff-algorithm=histogram, while recursive defaults to the
830               diff.algorithm config setting.
831
832           no-renames
833               Turn off rename detection. This overrides the merge.renames
834               configuration variable. See also git-diff(1) --no-renames.
835
836       resolve
837           This can only resolve two heads (i.e. the current branch and
838           another branch you pulled from) using a 3-way merge algorithm. It
839           tries to carefully detect criss-cross merge ambiguities. It does
840           not handle renames.
841
842       octopus
843           This resolves cases with more than two heads, but refuses to do a
844           complex merge that needs manual resolution. It is primarily meant
845           to be used for bundling topic branch heads together. This is the
846           default merge strategy when pulling or merging more than one
847           branch.
848
849       ours
850           This resolves any number of heads, but the resulting tree of the
851           merge is always that of the current branch head, effectively
852           ignoring all changes from all other branches. It is meant to be
853           used to supersede old development history of side branches. Note
854           that this is different from the -Xours option to the recursive
855           merge strategy.
856
857       subtree
858           This is a modified ort strategy. When merging trees A and B, if B
859           corresponds to a subtree of A, B is first adjusted to match the
860           tree structure of A, instead of reading the trees at the same
861           level. This adjustment is also done to the common ancestor tree.
862
863       With the strategies that use 3-way merge (including the default, ort),
864       if a change is made on both branches, but later reverted on one of the
865       branches, that change will be present in the merged result; some people
866       find this behavior confusing. It occurs because only the heads and the
867       merge base are considered when performing a merge, not the individual
868       commits. The merge algorithm therefore considers the reverted change as
869       no change at all, and substitutes the changed version instead.
870

DEFAULT BEHAVIOUR

872       Often people use git pull without giving any parameter. Traditionally,
873       this has been equivalent to saying git pull origin. However, when
874       configuration branch.<name>.remote is present while on branch <name>,
875       that value is used instead of origin.
876
877       In order to determine what URL to use to fetch from, the value of the
878       configuration remote.<origin>.url is consulted and if there is not any
879       such variable, the value on the URL: line in $GIT_DIR/remotes/<origin>
880       is used.
881
882       In order to determine what remote branches to fetch (and optionally
883       store in the remote-tracking branches) when the command is run without
884       any refspec parameters on the command line, values of the configuration
885       variable remote.<origin>.fetch are consulted, and if there aren’t any,
886       $GIT_DIR/remotes/<origin> is consulted and its Pull: lines are used. In
887       addition to the refspec formats described in the OPTIONS section, you
888       can have a globbing refspec that looks like this:
889
890           refs/heads/*:refs/remotes/origin/*
891
892       A globbing refspec must have a non-empty RHS (i.e. must store what were
893       fetched in remote-tracking branches), and its LHS and RHS must end with
894       /*. The above specifies that all remote branches are tracked using
895       remote-tracking branches in refs/remotes/origin/ hierarchy under the
896       same name.
897
898       The rule to determine which remote branch to merge after fetching is a
899       bit involved, in order not to break backward compatibility.
900
901       If explicit refspecs were given on the command line of git pull, they
902       are all merged.
903
904       When no refspec was given on the command line, then git pull uses the
905       refspec from the configuration or $GIT_DIR/remotes/<origin>. In such
906       cases, the following rules apply:
907
908        1. If branch.<name>.merge configuration for the current branch <name>
909           exists, that is the name of the branch at the remote site that is
910           merged.
911
912        2. If the refspec is a globbing one, nothing is merged.
913
914        3. Otherwise the remote branch of the first refspec is merged.
915

EXAMPLES

917       •   Update the remote-tracking branches for the repository you cloned
918           from, then merge one of them into your current branch:
919
920               $ git pull
921               $ git pull origin
922
923           Normally the branch merged in is the HEAD of the remote repository,
924           but the choice is determined by the branch.<name>.remote and
925           branch.<name>.merge options; see git-config(1) for details.
926
927       •   Merge into the current branch the remote branch next:
928
929               $ git pull origin next
930
931           This leaves a copy of next temporarily in FETCH_HEAD, and updates
932           the remote-tracking branch origin/next. The same can be done by
933           invoking fetch and merge:
934
935               $ git fetch origin
936               $ git merge origin/next
937
938       If you tried a pull which resulted in complex conflicts and would want
939       to start over, you can recover with git reset.
940

SECURITY

942       The fetch and push protocols are not designed to prevent one side from
943       stealing data from the other repository that was not intended to be
944       shared. If you have private data that you need to protect from a
945       malicious peer, your best option is to store it in another repository.
946       This applies to both clients and servers. In particular, namespaces on
947       a server are not effective for read access control; you should only
948       grant read access to a namespace to clients that you would trust with
949       read access to the entire repository.
950
951       The known attack vectors are as follows:
952
953        1. The victim sends "have" lines advertising the IDs of objects it has
954           that are not explicitly intended to be shared but can be used to
955           optimize the transfer if the peer also has them. The attacker
956           chooses an object ID X to steal and sends a ref to X, but isn’t
957           required to send the content of X because the victim already has
958           it. Now the victim believes that the attacker has X, and it sends
959           the content of X back to the attacker later. (This attack is most
960           straightforward for a client to perform on a server, by creating a
961           ref to X in the namespace the client has access to and then
962           fetching it. The most likely way for a server to perform it on a
963           client is to "merge" X into a public branch and hope that the user
964           does additional work on this branch and pushes it back to the
965           server without noticing the merge.)
966
967        2. As in #1, the attacker chooses an object ID X to steal. The victim
968           sends an object Y that the attacker already has, and the attacker
969           falsely claims to have X and not Y, so the victim sends Y as a
970           delta against X. The delta reveals regions of X that are similar to
971           Y to the attacker.
972

BUGS

974       Using --recurse-submodules can only fetch new commits in already
975       checked out submodules right now. When e.g. upstream added a new
976       submodule in the just fetched commits of the superproject the submodule
977       itself cannot be fetched, making it impossible to check out that
978       submodule later without having to do a fetch again. This is expected to
979       be fixed in a future Git version.
980

SEE ALSO

982       git-fetch(1), git-merge(1), git-config(1)
983

GIT

985       Part of the git(1) suite
986
987
988
989Git 2.43.0                        11/20/2023                       GIT-PULL(1)
Impressum