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`.
29 include::merge-options.txt[]
34 Instead of a merge, perform a rebase after fetching. If
35 there is a remote ref for the upstream branch, and this branch
36 was rebased since last fetched, the rebase uses that information
37 to avoid rebasing non-local changes. To make this the default
38 for branch `<name>`, set configuration `branch.<name>.rebase`
41 *NOTE:* This is a potentially _dangerous_ mode of operation.
42 It rewrites history, which does not bode well when you
43 published that history already. Do *not* use this option
44 unless you have read linkgit:git-rebase[1] carefully.
47 Override earlier --rebase.
49 include::fetch-options.txt[]
51 include::pull-fetch-param.txt[]
53 include::urls-remotes.txt[]
55 include::merge-strategies.txt[]
60 Often people use `git pull` without giving any parameter.
61 Traditionally, this has been equivalent to saying `git pull
62 origin`. However, when configuration `branch.<name>.remote` is
63 present while on branch `<name>`, that value is used instead of
66 In order to determine what URL to use to fetch from, the value
67 of the configuration `remote.<origin>.url` is consulted
68 and if there is not any such variable, the value on `URL: ` line
69 in `$GIT_DIR/remotes/<origin>` file is used.
71 In order to determine what remote branches to fetch (and
72 optionally store in the tracking branches) when the command is
73 run without any refspec parameters on the command line, values
74 of the configuration variable `remote.<origin>.fetch` are
75 consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
76 file is consulted and its `Pull: ` lines are used.
77 In addition to the refspec formats described in the OPTIONS
78 section, you can have a globbing refspec that looks like this:
81 refs/heads/*:refs/remotes/origin/*
84 A globbing refspec must have a non-empty RHS (i.e. must store
85 what were fetched in tracking branches), and its LHS and RHS
86 must end with `/*`. The above specifies that all remote
87 branches are tracked using tracking branches in
88 `refs/remotes/origin/` hierarchy under the same name.
90 The rule to determine which remote branch to merge after
91 fetching is a bit involved, in order not to break backward
94 If explicit refspecs were given on the command
95 line of `git pull`, they are all merged.
97 When no refspec was given on the command line, then `git pull`
98 uses the refspec from the configuration or
99 `$GIT_DIR/remotes/<origin>`. In such cases, the following
102 . If `branch.<name>.merge` configuration for the current
103 branch `<name>` exists, that is the name of the branch at the
104 remote site that is merged.
106 . If the refspec is a globbing one, nothing is merged.
108 . Otherwise the remote branch of the first refspec is merged.
114 * Update the remote-tracking branches for the repository
115 you cloned from, then merge one of them into your
118 ------------------------------------------------
119 $ git pull, git pull origin
120 ------------------------------------------------
122 Normally the branch merged in is the HEAD of the remote repository,
123 but the choice is determined by the branch.<name>.remote and
124 branch.<name>.merge options; see linkgit:git-config[1] for details.
126 * Merge into the current branch the remote branch `next`:
128 ------------------------------------------------
129 $ git pull origin next
130 ------------------------------------------------
132 This leaves a copy of `next` temporarily in FETCH_HEAD, but
133 does not update any remote-tracking branches.
135 * Bundle local branch `fixes` and `enhancements` on top of
136 the current branch, making an Octopus merge:
138 ------------------------------------------------
139 $ git pull . fixes enhancements
140 ------------------------------------------------
142 This `git pull .` syntax is equivalent to `git merge`.
144 * Merge local branch `obsolete` into the current branch, using `ours`
147 ------------------------------------------------
148 $ git pull -s ours . obsolete
149 ------------------------------------------------
151 * Merge local branch `maint` into the current branch, but do not make
152 a commit automatically:
154 ------------------------------------------------
155 $ git pull --no-commit . maint
156 ------------------------------------------------
158 This can be used when you want to include further changes to the
159 merge, or want to write your own merge commit message.
161 You should refrain from abusing this option to sneak substantial
162 changes into a merge commit. Small fixups like bumping
163 release/version name would be acceptable.
165 * Command line pull of multiple branches from one repository:
167 ------------------------------------------------
168 $ git checkout master
169 $ git fetch origin +pu:pu maint:tmp
171 ------------------------------------------------
173 This updates (or creates, as necessary) branches `pu` and `tmp` in
174 the local repository by fetching from the branches (respectively)
175 `pu` and `maint` from the remote repository.
177 The `pu` branch will be updated even if it is does not fast-forward;
178 the others will not be.
180 The final command then merges the newly fetched `tmp` into master.
183 If you tried a pull which resulted in a complex conflicts and
184 would want to start over, you can recover with
185 linkgit:git-reset[1].
190 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
195 Written by Linus Torvalds <torvalds@osdl.org>
196 and Junio C Hamano <junkio@cox.net>
200 Documentation by Jon Loeliger,
202 Junio C Hamano and the git-list <git@vger.kernel.org>.
206 Part of the linkgit:git[1] suite