6 git-pull - Fetch from and merge with another repository or a local branch
11 'git pull' <options> <repository> <refspec>...
16 Runs 'git fetch' with the given parameters, and calls 'git merge'
17 to merge the retrieved head(s) into the current branch.
18 With `--rebase`, calls 'git rebase' instead of 'git merge'.
20 Note that you can use `.` (current directory) as the
21 <repository> to pull from the local repository -- this is useful
22 when merging local branches into the current branch.
24 Also note that options meant for 'git pull' itself and underlying
25 'git merge' must be given before the options meant for 'git fetch'.
27 *Warning*: Running 'git pull' (actually, the underlying 'git merge')
28 with uncommitted changes is discouraged: while possible, it leaves you
29 in a state that is hard to back out of in the case of a conflict.
36 Pass --quiet to git-fetch and git-merge.
40 Pass --verbose to git-fetch and git-merge.
42 Options related to merging
43 ~~~~~~~~~~~~~~~~~~~~~~~~~~
45 include::merge-options.txt[]
50 Instead of a merge, perform a rebase after fetching. If
51 there is a remote ref for the upstream branch, and this branch
52 was rebased since last fetched, the rebase uses that information
53 to avoid rebasing non-local changes. To make this the default
54 for branch `<name>`, set configuration `branch.<name>.rebase`
58 This is a potentially _dangerous_ mode of operation.
59 It rewrites history, which does not bode well when you
60 published that history already. Do *not* use this option
61 unless you have read linkgit:git-rebase[1] carefully.
64 Override earlier --rebase.
66 Options related to fetching
67 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 include::fetch-options.txt[]
71 include::pull-fetch-param.txt[]
73 include::urls-remotes.txt[]
75 include::merge-strategies.txt[]
80 Often people use `git pull` without giving any parameter.
81 Traditionally, this has been equivalent to saying `git pull
82 origin`. However, when configuration `branch.<name>.remote` is
83 present while on branch `<name>`, that value is used instead of
86 In order to determine what URL to use to fetch from, the value
87 of the configuration `remote.<origin>.url` is consulted
88 and if there is not any such variable, the value on `URL: ` line
89 in `$GIT_DIR/remotes/<origin>` file is used.
91 In order to determine what remote branches to fetch (and
92 optionally store in the tracking branches) when the command is
93 run without any refspec parameters on the command line, values
94 of the configuration variable `remote.<origin>.fetch` are
95 consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
96 file is consulted and its `Pull: ` lines are used.
97 In addition to the refspec formats described in the OPTIONS
98 section, you can have a globbing refspec that looks like this:
101 refs/heads/*:refs/remotes/origin/*
104 A globbing refspec must have a non-empty RHS (i.e. must store
105 what were fetched in tracking branches), and its LHS and RHS
106 must end with `/*`. The above specifies that all remote
107 branches are tracked using tracking branches in
108 `refs/remotes/origin/` hierarchy under the same name.
110 The rule to determine which remote branch to merge after
111 fetching is a bit involved, in order not to break backward
114 If explicit refspecs were given on the command
115 line of `git pull`, they are all merged.
117 When no refspec was given on the command line, then `git pull`
118 uses the refspec from the configuration or
119 `$GIT_DIR/remotes/<origin>`. In such cases, the following
122 . If `branch.<name>.merge` configuration for the current
123 branch `<name>` exists, that is the name of the branch at the
124 remote site that is merged.
126 . If the refspec is a globbing one, nothing is merged.
128 . Otherwise the remote branch of the first refspec is merged.
134 * Update the remote-tracking branches for the repository
135 you cloned from, then merge one of them into your
138 ------------------------------------------------
139 $ git pull, git pull origin
140 ------------------------------------------------
142 Normally the branch merged in is the HEAD of the remote repository,
143 but the choice is determined by the branch.<name>.remote and
144 branch.<name>.merge options; see linkgit:git-config[1] for details.
146 * Merge into the current branch the remote branch `next`:
148 ------------------------------------------------
149 $ git pull origin next
150 ------------------------------------------------
152 This leaves a copy of `next` temporarily in FETCH_HEAD, but
153 does not update any remote-tracking branches. Using remote-tracking
154 branches, the same can be done by invoking fetch and merge:
156 ------------------------------------------------
158 $ git merge origin/next
159 ------------------------------------------------
162 If you tried a pull which resulted in a complex conflicts and
163 would want to start over, you can recover with 'git reset'.
168 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
173 Written by Linus Torvalds <torvalds@osdl.org>
174 and Junio C Hamano <gitster@pobox.com>
178 Documentation by Jon Loeliger,
180 Junio C Hamano and the git-list <git@vger.kernel.org>.
184 Part of the linkgit:git[1] suite