1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
\r
4 <article lang="en" id="git-pull(1)">
\r
6 <title>git-pull(1)</title>
\r
8 <primary>git-pull(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-pull - Fetch from and merge with another repository or a local branch</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
17 <simpara><emphasis>git pull</emphasis> <options> <repository> <refspec>…</simpara>
\r
19 <simplesect id="_description">
\r
20 <title>DESCRIPTION</title>
\r
21 <simpara>Runs <emphasis>git-fetch</emphasis> with the given parameters, and calls <emphasis>git-merge</emphasis>
\r
22 to merge the retrieved head(s) into the current branch.
\r
23 With <literal>--rebase</literal>, calls <emphasis>git-rebase</emphasis> instead of <emphasis>git-merge</emphasis>.</simpara>
\r
24 <simpara>Note that you can use <literal>.</literal> (current directory) as the
\r
25 <repository> to pull from the local repository — this is useful
\r
26 when merging local branches into the current branch.</simpara>
\r
27 <simpara>Also note that options meant for <emphasis>git-pull</emphasis> itself and underlying
\r
28 <emphasis>git-merge</emphasis> must be given before the options meant for <emphasis>git-fetch</emphasis>.</simpara>
\r
30 <simplesect id="_options">
\r
31 <title>OPTIONS</title>
\r
65 Show a diffstat at the end of the merge. The diffstat is also
\r
66 controlled by the configuration option merge.stat.
\r
79 Do not show a diffstat at the end of the merge.
\r
92 Synonyms to --stat and --no-stat; these are deprecated and will be
\r
93 removed in the future.
\r
103 In addition to branch names, populate the log message with
\r
104 one-line descriptions from the actual commits that are being
\r
115 Do not list one-line descriptions from the actual commits being
\r
126 Perform the merge but pretend the merge failed and do
\r
127 not autocommit, to give the user a chance to inspect and
\r
128 further tweak the merge result before committing.
\r
138 Perform the merge and commit the result. This option can
\r
139 be used to override --no-commit.
\r
149 Produce the working tree and index state as if a real
\r
150 merge happened, but do not actually make a commit or
\r
151 move the <literal>HEAD</literal>, nor record <literal>$GIT_DIR/MERGE_HEAD</literal> to
\r
152 cause the next <literal>git commit</literal> command to create a merge
\r
153 commit. This allows you to create a single commit on
\r
154 top of the current branch whose effect is the same as
\r
155 merging another branch (or more in case of an octopus).
\r
165 Perform the merge and commit the result. This option can
\r
166 be used to override --squash.
\r
176 Generate a merge commit even if the merge resolved as a
\r
187 Do not generate a merge commit if the merge resolved as
\r
188 a fast-forward, only update the branch pointer. This is
\r
189 the default behavior of git-merge.
\r
195 -s <strategy>
\r
198 --strategy=<strategy>
\r
202 Use the given merge strategy; can be supplied more than
\r
203 once to specify them in the order they should be tried.
\r
204 If there is no <literal>-s</literal> option, a built-in list of strategies
\r
205 is used instead (<emphasis>git-merge-recursive</emphasis> when merging a single
\r
206 head, <emphasis>git-merge-octopus</emphasis> otherwise).
\r
218 Instead of a merge, perform a rebase after fetching. If
\r
219 there is a remote ref for the upstream branch, and this branch
\r
220 was rebased since last fetched, the rebase uses that information
\r
221 to avoid rebasing non-local changes. To make this the default
\r
222 for branch <literal><name></literal>, set configuration <literal>branch.<name>.rebase</literal>
\r
223 to <literal>true</literal>.
\r
225 <note><simpara>This is a potentially <emphasis>dangerous</emphasis> mode of operation.
\r
226 It rewrites history, which does not bode well when you
\r
227 published that history already. Do <emphasis role="strong">not</emphasis> use this option
\r
228 unless you have read <xref linkend="git-rebase(1)"/> carefully.</simpara></note>
\r
237 Override earlier --rebase.
\r
250 Pass --quiet to git-fetch-pack and silence any other internally
\r
277 Append ref names and object names of fetched refs to the
\r
278 existing contents of <literal>.git/FETCH_HEAD</literal>. Without this
\r
279 option old data in <literal>.git/FETCH_HEAD</literal> will be overwritten.
\r
285 --upload-pack <upload-pack>
\r
289 When given, and the repository to fetch from is handled
\r
290 by <emphasis>git-fetch-pack</emphasis>, <emphasis>--exec=<upload-pack></emphasis> is passed to
\r
291 the command to specify non-default path for the command
\r
292 run on the other end.
\r
305 When <emphasis>git-fetch</emphasis> is used with <literal><rbranch>:<lbranch></literal>
\r
306 refspec, it refuses to update the local branch
\r
307 <literal><lbranch></literal> unless the remote branch <literal><rbranch></literal> it
\r
308 fetches is a descendant of <literal><lbranch></literal>. This option
\r
309 overrides that check.
\r
319 By default, tags that point at objects that are downloaded
\r
320 from the remote repository are fetched and stored locally.
\r
321 This option disables this automatic tag following.
\r
334 Most of the tags are fetched automatically as branch
\r
335 heads are downloaded, but tags that do not point at
\r
336 objects reachable from the branch heads that are being
\r
337 tracked will not be fetched by this mechanism. This
\r
338 flag lets all tags and their associated objects be
\r
352 Keep downloaded pack.
\r
365 By default <emphasis>git-fetch</emphasis> refuses to update the head which
\r
366 corresponds to the current branch. This flag disables the
\r
367 check. This is purely for the internal use for <emphasis>git-pull</emphasis>
\r
368 to communicate with <emphasis>git-fetch</emphasis>, and unless you are
\r
369 implementing your own Porcelain you are not supposed to
\r
376 --depth=<depth>
\r
380 Deepen the history of a <emphasis>shallow</emphasis> repository created by
\r
381 <literal>git clone</literal> with <literal>--depth=<depth></literal> option (see <xref linkend="git-clone(1)"/>)
\r
382 by the specified number of commits.
\r
392 The "remote" repository that is the source of a fetch
\r
393 or pull operation. This parameter can be either a URL
\r
394 (see the section <link linkend="URLS">GIT URLS</link> below) or the name
\r
395 of a remote (see the section <link linkend="REMOTES">REMOTES</link> below).
\r
405 The format of a <refspec> parameter is an optional plus
\r
406 <literal>+</literal>, followed by the source ref <src>, followed
\r
407 by a colon <literal>:</literal>, followed by the destination ref <dst>.
\r
409 <simpara>The remote ref that matches <src>
\r
410 is fetched, and if <dst> is not empty string, the local
\r
411 ref that matches it is fast forwarded using <src>.
\r
412 If the optional plus <literal>+</literal> is used, the local ref
\r
413 is updated even if it does not result in a fast forward
\r
415 <note><simpara>If the remote branch from which you want to pull is
\r
416 modified in non-linear ways such as being rewound and
\r
417 rebased frequently, then a pull will attempt a merge with
\r
418 an older version of itself, likely conflict, and fail.
\r
419 It is under these conditions that you would want to use
\r
420 the <literal>+</literal> sign to indicate non-fast-forward updates will
\r
421 be needed. There is currently no easy way to determine
\r
422 or declare that a branch will be made available in a
\r
423 repository with this behavior; the pulling user simply
\r
424 must know this is the expected usage pattern for a branch.</simpara></note>
\r
425 <note><simpara>You never do your own development on branches that appear
\r
426 on the right hand side of a <refspec> colon on <literal>Pull:</literal> lines;
\r
427 they are to be updated by <emphasis>git-fetch</emphasis>. If you intend to do
\r
428 development derived from a remote branch <literal>B</literal>, have a <literal>Pull:</literal>
\r
429 line to track it (i.e. <literal>Pull: B:remote-B</literal>), and have a separate
\r
430 branch <literal>my-B</literal> to do your development on top of it. The latter
\r
431 is created by <literal>git branch my-B remote-B</literal> (or its equivalent <literal>git
\r
432 checkout -b my-B remote-B</literal>). Run <literal>git fetch</literal> to keep track of
\r
433 the progress of the remote side, and when you see something new
\r
434 on the remote branch, merge it into your development branch with
\r
435 <literal>git pull . remote-B</literal>, while you are on <literal>my-B</literal> branch.</simpara></note>
\r
436 <note><simpara>There is a difference between listing multiple <refspec>
\r
437 directly on <emphasis>git-pull</emphasis> command line and having multiple
\r
438 <literal>Pull:</literal> <refspec> lines for a <repository> and running
\r
439 <emphasis>git-pull</emphasis> command without any explicit <refspec> parameters.
\r
440 <refspec> listed explicitly on the command line are always
\r
441 merged into the current branch after fetching. In other words,
\r
442 if you list more than one remote refs, you would be making
\r
443 an Octopus. While <emphasis>git-pull</emphasis> run without any explicit <refspec>
\r
444 parameter takes default <refspec>s from <literal>Pull:</literal> lines, it
\r
445 merges only the first <refspec> found into the current branch,
\r
446 after fetching all the remote refs. This is because making an
\r
447 Octopus from remote refs is rarely done, while keeping track
\r
448 of multiple remote heads in one-go by fetching more than one
\r
449 is often useful.</simpara></note>
\r
450 <simpara>Some short-cut notations are also supported.</simpara>
\r
454 <literal>tag <tag></literal> means the same as <literal>refs/tags/<tag>:refs/tags/<tag></literal>;
\r
455 it requests fetching everything up to the given tag.
\r
460 A parameter <ref> without a colon is equivalent to
\r
461 <ref>: when pulling/fetching, so it merges <ref> into the current
\r
462 branch without storing the remote branch anywhere locally
\r
470 <simplesect id="_git_urls_anchor_id_urls_xreflabel_urls">
\r
471 <title>GIT URLS<anchor id="URLS" xreflabel="[URLS]"/></title>
\r
472 <simpara>One of the following notations can be used
\r
473 to name the remote repository:</simpara>
\r
478 rsync://host.xz/path/to/repo.git/
\r
483 <ulink url="http://host.xz[:port]/path/to/repo.git/">http://host.xz[:port]/path/to/repo.git/</ulink>
\r
488 <ulink url="https://host.xz[:port]/path/to/repo.git/">https://host.xz[:port]/path/to/repo.git/</ulink>
\r
493 git://host.xz[:port]/path/to/repo.git/
\r
498 git://host.xz[:port]/~user/path/to/repo.git/
\r
503 ssh://[user@]host.xz[:port]/path/to/repo.git/
\r
508 ssh://[user@]host.xz/path/to/repo.git/
\r
513 ssh://[user@]host.xz/~user/path/to/repo.git/
\r
518 ssh://[user@]host.xz/~/path/to/repo.git
\r
523 <simpara>SSH is the default transport protocol over the network. You can
\r
524 optionally specify which user to log-in as, and an alternate,
\r
525 scp-like syntax is also supported. Both syntaxes support
\r
526 username expansion, as does the native git protocol, but
\r
527 only the former supports port specification. The following
\r
528 three are identical to the last three above, respectively:</simpara>
\r
533 [user@]host.xz:/path/to/repo.git/
\r
538 [user@]host.xz:~user/path/to/repo.git/
\r
543 [user@]host.xz:path/to/repo.git
\r
548 <simpara>To sync with a local directory, you can use:</simpara>
\r
558 <ulink url="file:///path/to/repo.git/">file:///path/to/repo.git/</ulink>
\r
563 <simpara>They are mostly equivalent, except when cloning. See
\r
564 <xref linkend="git-clone(1)"/> for details.</simpara>
\r
565 <simpara>If there are a large number of similarly-named remote repositories and
\r
566 you want to use a different format for them (such that the URLs you
\r
567 use will be rewritten into URLs that work), you can create a
\r
568 configuration section of the form:</simpara>
\r
569 <literallayout> [url "<actual url base>"]
\r
570 insteadOf = <other url base></literallayout>
\r
571 <simpara>For example, with this:</simpara>
\r
572 <literallayout> [url "git://git.host.xz/"]
\r
573 insteadOf = host.xz:/path/to/
\r
574 insteadOf = work:</literallayout>
\r
575 <simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
\r
576 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>
\r
578 <simplesect id="_remotes_anchor_id_remotes_xreflabel_remotes">
\r
579 <title>REMOTES<anchor id="REMOTES" xreflabel="[REMOTES]"/></title>
\r
580 <simpara>The name of one of the following can be used instead
\r
581 of a URL as <literal><repository></literal> argument:</simpara>
\r
585 a remote in the git configuration file: <literal>$GIT_DIR/config</literal>,
\r
590 a file in the <literal>$GIT_DIR/remotes</literal> directory, or
\r
595 a file in the <literal>$GIT_DIR/branches</literal> directory.
\r
599 <simpara>All of these also allow you to omit the refspec from the command line
\r
600 because they each contain a refspec which git will use by default.</simpara>
\r
601 <simplesect id="_named_remote_in_configuration_file">
\r
602 <title>Named remote in configuration file</title>
\r
603 <simpara>You can choose to provide the name of a remote which you had previously
\r
604 configured using <xref linkend="git-remote(1)"/>, <xref linkend="git-config(1)"/>
\r
605 or even by a manual edit to the <literal>$GIT_DIR/config</literal> file. The URL of
\r
606 this remote will be used to access the repository. The refspec
\r
607 of this remote will be used by default when you do
\r
608 not provide a refspec on the command line. The entry in the
\r
609 config file would appear like this:</simpara>
\r
610 <literallayout> [remote "<name>"]
\r
612 push = <refspec>
\r
613 fetch = <refspec></literallayout>
\r
615 <simplesect id="_named_file_in_literal_git_dir_remotes_literal">
\r
616 <title>Named file in <literal>$GIT_DIR/remotes</literal></title>
\r
617 <simpara>You can choose to provide the name of a
\r
618 file in <literal>$GIT_DIR/remotes</literal>. The URL
\r
619 in this file will be used to access the repository. The refspec
\r
620 in this file will be used as default when you do not
\r
621 provide a refspec on the command line. This file should have the
\r
622 following format:</simpara>
\r
623 <literallayout> URL: one of the above URL format
\r
624 Push: <refspec>
\r
625 Pull: <refspec></literallayout>
\r
626 <simpara><literal>Push:</literal> lines are used by <emphasis>git-push</emphasis> and
\r
627 <literal>Pull:</literal> lines are used by <emphasis>git-pull</emphasis> and <emphasis>git-fetch</emphasis>.
\r
628 Multiple <literal>Push:</literal> and <literal>Pull:</literal> lines may
\r
629 be specified for additional branch mappings.</simpara>
\r
631 <simplesect id="_named_file_in_literal_git_dir_branches_literal">
\r
632 <title>Named file in <literal>$GIT_DIR/branches</literal></title>
\r
633 <simpara>You can choose to provide the name of a
\r
634 file in <literal>$GIT_DIR/branches</literal>.
\r
635 The URL in this file will be used to access the repository.
\r
636 This file should have the following format:</simpara>
\r
637 <literallayout> <url>#<head></literallayout>
\r
638 <simpara><literal><url></literal> is required; <literal>#<head></literal> is optional.</simpara>
\r
639 <simpara>Depending on the operation, git will use one of the following
\r
640 refspecs, if you don’t provide one on the command line.
\r
641 <literal><branch></literal> is the name of this file in <literal>$GIT_DIR/branches</literal> and
\r
642 <literal><head></literal> defaults to <literal>master</literal>.</simpara>
\r
643 <simpara>git fetch uses:</simpara>
\r
644 <literallayout> refs/heads/<head>:refs/heads/<branch></literallayout>
\r
645 <simpara>git push uses:</simpara>
\r
646 <literallayout> HEAD:refs/heads/<head></literallayout>
\r
649 <simplesect id="_merge_strategies">
\r
650 <title>MERGE STRATEGIES</title>
\r
658 This can only resolve two heads (i.e. the current branch
\r
659 and another branch you pulled from) using 3-way merge
\r
660 algorithm. It tries to carefully detect criss-cross
\r
661 merge ambiguities and is considered generally safe and
\r
672 This can only resolve two heads using 3-way merge
\r
673 algorithm. When there are more than one common
\r
674 ancestors that can be used for 3-way merge, it creates a
\r
675 merged tree of the common ancestors and uses that as
\r
676 the reference tree for the 3-way merge. This has been
\r
677 reported to result in fewer merge conflicts without
\r
678 causing mis-merges by tests done on actual merge commits
\r
679 taken from Linux 2.6 kernel development history.
\r
680 Additionally this can detect and handle merges involving
\r
681 renames. This is the default merge strategy when
\r
682 pulling or merging one branch.
\r
692 This resolves more than two-head case, but refuses to do
\r
693 complex merge that needs manual resolution. It is
\r
694 primarily meant to be used for bundling topic branch
\r
695 heads together. This is the default merge strategy when
\r
696 pulling or merging more than one branches.
\r
706 This resolves any number of heads, but the result of the
\r
707 merge is always the current branch head. It is meant to
\r
708 be used to supersede old development history of side
\r
719 This is a modified recursive strategy. When merging trees A and
\r
720 B, if B corresponds to a subtree of A, B is first adjusted to
\r
721 match the tree structure of A, instead of reading the trees at
\r
722 the same level. This adjustment is also done to the common
\r
729 <simplesect id="_default_behaviour">
\r
730 <title>DEFAULT BEHAVIOUR</title>
\r
731 <simpara>Often people use <literal>git pull</literal> without giving any parameter.
\r
732 Traditionally, this has been equivalent to saying <literal>git pull
\r
733 origin</literal>. However, when configuration <literal>branch.<name>.remote</literal> is
\r
734 present while on branch <literal><name></literal>, that value is used instead of
\r
735 <literal>origin</literal>.</simpara>
\r
736 <simpara>In order to determine what URL to use to fetch from, the value
\r
737 of the configuration <literal>remote.<origin>.url</literal> is consulted
\r
738 and if there is not any such variable, the value on <literal>URL: ` line
\r
739 in `$GIT_DIR/remotes/<origin></literal> file is used.</simpara>
\r
740 <simpara>In order to determine what remote branches to fetch (and
\r
741 optionally store in the tracking branches) when the command is
\r
742 run without any refspec parameters on the command line, values
\r
743 of the configuration variable <literal>remote.<origin>.fetch</literal> are
\r
744 consulted, and if there aren’t any, <literal>$GIT_DIR/remotes/<origin></literal>
\r
745 file is consulted and its `Pull: ` lines are used.
\r
746 In addition to the refspec formats described in the OPTIONS
\r
747 section, you can have a globbing refspec that looks like this:</simpara>
\r
748 <literallayout>refs/heads/*:refs/remotes/origin/*</literallayout>
\r
749 <simpara>A globbing refspec must have a non-empty RHS (i.e. must store
\r
750 what were fetched in tracking branches), and its LHS and RHS
\r
751 must end with <literal>/*</literal>. The above specifies that all remote
\r
752 branches are tracked using tracking branches in
\r
753 <literal>refs/remotes/origin/</literal> hierarchy under the same name.</simpara>
\r
754 <simpara>The rule to determine which remote branch to merge after
\r
755 fetching is a bit involved, in order not to break backward
\r
756 compatibility.</simpara>
\r
757 <simpara>If explicit refspecs were given on the command
\r
758 line of <literal>git pull</literal>, they are all merged.</simpara>
\r
759 <simpara>When no refspec was given on the command line, then <literal>git pull</literal>
\r
760 uses the refspec from the configuration or
\r
761 <literal>$GIT_DIR/remotes/<origin></literal>. In such cases, the following
\r
762 rules apply:</simpara>
\r
763 <orderedlist numeration="arabic">
\r
766 If <literal>branch.<name>.merge</literal> configuration for the current
\r
767 branch <literal><name></literal> exists, that is the name of the branch at the
\r
768 remote site that is merged.
\r
773 If the refspec is a globbing one, nothing is merged.
\r
778 Otherwise the remote branch of the first refspec is merged.
\r
783 <simplesect id="_examples">
\r
784 <title>EXAMPLES</title>
\r
788 Update the remote-tracking branches for the repository
\r
789 you cloned from, then merge one of them into your
\r
792 <literallayout>$ git pull, git pull origin</literallayout>
\r
793 <simpara>Normally the branch merged in is the HEAD of the remote repository,
\r
794 but the choice is determined by the branch.<name>.remote and
\r
795 branch.<name>.merge options; see <xref linkend="git-config(1)"/> for details.</simpara>
\r
799 Merge into the current branch the remote branch <literal>next</literal>:
\r
801 <literallayout>$ git pull origin next</literallayout>
\r
802 <simpara>This leaves a copy of <literal>next</literal> temporarily in FETCH_HEAD, but
\r
803 does not update any remote-tracking branches.</simpara>
\r
807 Bundle local branch <literal>fixes</literal> and <literal>enhancements</literal> on top of
\r
808 the current branch, making an Octopus merge:
\r
810 <literallayout>$ git pull . fixes enhancements</literallayout>
\r
811 <simpara>This <literal>git pull .</literal> syntax is equivalent to <literal>git merge</literal>.</simpara>
\r
815 Merge local branch <literal>obsolete</literal> into the current branch, using <literal>ours</literal>
\r
818 <literallayout>$ git pull -s ours . obsolete</literallayout>
\r
822 Merge local branch <literal>maint</literal> into the current branch, but do not make
\r
823 a commit automatically:
\r
825 <literallayout>$ git pull --no-commit . maint</literallayout>
\r
826 <simpara>This can be used when you want to include further changes to the
\r
827 merge, or want to write your own merge commit message.</simpara>
\r
828 <simpara>You should refrain from abusing this option to sneak substantial
\r
829 changes into a merge commit. Small fixups like bumping
\r
830 release/version name would be acceptable.</simpara>
\r
834 Command line pull of multiple branches from one repository:
\r
836 <literallayout>$ git checkout master
\r
837 $ git fetch origin +pu:pu maint:tmp
\r
838 $ git pull . tmp</literallayout>
\r
839 <simpara>This updates (or creates, as necessary) branches <literal>pu</literal> and <literal>tmp</literal> in
\r
840 the local repository by fetching from the branches (respectively)
\r
841 <literal>pu</literal> and <literal>maint</literal> from the remote repository.</simpara>
\r
842 <simpara>The <literal>pu</literal> branch will be updated even if it is does not fast-forward;
\r
843 the others will not be.</simpara>
\r
844 <simpara>The final command then merges the newly fetched <literal>tmp</literal> into master.</simpara>
\r
847 <simpara>If you tried a pull which resulted in a complex conflicts and
\r
848 would want to start over, you can recover with <emphasis>git-reset</emphasis>.</simpara>
\r
850 <simplesect id="_see_also">
\r
851 <title>SEE ALSO</title>
\r
852 <simpara><xref linkend="git-fetch(1)"/>, <xref linkend="git-merge(1)"/>, <xref linkend="git-config(1)"/></simpara>
\r
854 <simplesect id="_author">
\r
855 <title>Author</title>
\r
856 <simpara>Written by Linus Torvalds <<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>>
\r
857 and Junio C Hamano <<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>></simpara>
\r
859 <simplesect id="_documentation">
\r
860 <title>Documentation</title>
\r
861 <simpara>Documentation by Jon Loeliger,
\r
863 Junio C Hamano and the git-list <<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>>.</simpara>
\r
865 <simplesect id="_git">
\r
867 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
\r