Documentation/git-pull.txt: Add subtitles above included option files
[git/git.git] / Documentation / git-pull.txt
1 git-pull(1)
2 ===========
3
4 NAME
5 ----
6 git-pull - Fetch from and merge with another repository or a local branch
7
8
9 SYNOPSIS
10 --------
11 'git pull' <options> <repository> <refspec>...
12
13
14 DESCRIPTION
15 -----------
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'.
19
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.
23
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'.
26
27 OPTIONS
28 -------
29
30 Options related to merging
31 ~~~~~~~~~~~~~~~~~~~~~~~~~~
32
33 include::merge-options.txt[]
34
35 :git-pull: 1
36
37 --rebase::
38 Instead of a merge, perform a rebase after fetching. If
39 there is a remote ref for the upstream branch, and this branch
40 was rebased since last fetched, the rebase uses that information
41 to avoid rebasing non-local changes. To make this the default
42 for branch `<name>`, set configuration `branch.<name>.rebase`
43 to `true`.
44 +
45 [NOTE]
46 This is a potentially _dangerous_ mode of operation.
47 It rewrites history, which does not bode well when you
48 published that history already. Do *not* use this option
49 unless you have read linkgit:git-rebase[1] carefully.
50
51 --no-rebase::
52 Override earlier --rebase.
53
54 Options related to fetching
55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
57 include::fetch-options.txt[]
58
59 include::pull-fetch-param.txt[]
60
61 include::urls-remotes.txt[]
62
63 include::merge-strategies.txt[]
64
65 DEFAULT BEHAVIOUR
66 -----------------
67
68 Often people use `git pull` without giving any parameter.
69 Traditionally, this has been equivalent to saying `git pull
70 origin`. However, when configuration `branch.<name>.remote` is
71 present while on branch `<name>`, that value is used instead of
72 `origin`.
73
74 In order to determine what URL to use to fetch from, the value
75 of the configuration `remote.<origin>.url` is consulted
76 and if there is not any such variable, the value on `URL: ` line
77 in `$GIT_DIR/remotes/<origin>` file is used.
78
79 In order to determine what remote branches to fetch (and
80 optionally store in the tracking branches) when the command is
81 run without any refspec parameters on the command line, values
82 of the configuration variable `remote.<origin>.fetch` are
83 consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
84 file is consulted and its `Pull: ` lines are used.
85 In addition to the refspec formats described in the OPTIONS
86 section, you can have a globbing refspec that looks like this:
87
88 ------------
89 refs/heads/*:refs/remotes/origin/*
90 ------------
91
92 A globbing refspec must have a non-empty RHS (i.e. must store
93 what were fetched in tracking branches), and its LHS and RHS
94 must end with `/*`. The above specifies that all remote
95 branches are tracked using tracking branches in
96 `refs/remotes/origin/` hierarchy under the same name.
97
98 The rule to determine which remote branch to merge after
99 fetching is a bit involved, in order not to break backward
100 compatibility.
101
102 If explicit refspecs were given on the command
103 line of `git pull`, they are all merged.
104
105 When no refspec was given on the command line, then `git pull`
106 uses the refspec from the configuration or
107 `$GIT_DIR/remotes/<origin>`. In such cases, the following
108 rules apply:
109
110 . If `branch.<name>.merge` configuration for the current
111 branch `<name>` exists, that is the name of the branch at the
112 remote site that is merged.
113
114 . If the refspec is a globbing one, nothing is merged.
115
116 . Otherwise the remote branch of the first refspec is merged.
117
118
119 EXAMPLES
120 --------
121
122 * Update the remote-tracking branches for the repository
123 you cloned from, then merge one of them into your
124 current branch:
125 +
126 ------------------------------------------------
127 $ git pull, git pull origin
128 ------------------------------------------------
129 +
130 Normally the branch merged in is the HEAD of the remote repository,
131 but the choice is determined by the branch.<name>.remote and
132 branch.<name>.merge options; see linkgit:git-config[1] for details.
133
134 * Merge into the current branch the remote branch `next`:
135 +
136 ------------------------------------------------
137 $ git pull origin next
138 ------------------------------------------------
139 +
140 This leaves a copy of `next` temporarily in FETCH_HEAD, but
141 does not update any remote-tracking branches.
142
143 * Bundle local branch `fixes` and `enhancements` on top of
144 the current branch, making an Octopus merge:
145 +
146 ------------------------------------------------
147 $ git pull . fixes enhancements
148 ------------------------------------------------
149 +
150 This `git pull .` syntax is equivalent to `git merge`.
151
152 * Merge local branch `obsolete` into the current branch, using `ours`
153 merge strategy:
154 +
155 ------------------------------------------------
156 $ git pull -s ours . obsolete
157 ------------------------------------------------
158
159 * Merge local branch `maint` into the current branch, but do not make
160 a commit automatically:
161 +
162 ------------------------------------------------
163 $ git pull --no-commit . maint
164 ------------------------------------------------
165 +
166 This can be used when you want to include further changes to the
167 merge, or want to write your own merge commit message.
168 +
169 You should refrain from abusing this option to sneak substantial
170 changes into a merge commit. Small fixups like bumping
171 release/version name would be acceptable.
172
173 * Command line pull of multiple branches from one repository:
174 +
175 ------------------------------------------------
176 $ git checkout master
177 $ git fetch origin +pu:pu maint:tmp
178 $ git pull . tmp
179 ------------------------------------------------
180 +
181 This updates (or creates, as necessary) branches `pu` and `tmp` in
182 the local repository by fetching from the branches (respectively)
183 `pu` and `maint` from the remote repository.
184 +
185 The `pu` branch will be updated even if it is does not fast-forward;
186 the others will not be.
187 +
188 The final command then merges the newly fetched `tmp` into master.
189
190
191 If you tried a pull which resulted in a complex conflicts and
192 would want to start over, you can recover with 'git-reset'.
193
194
195 SEE ALSO
196 --------
197 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
198
199
200 Author
201 ------
202 Written by Linus Torvalds <torvalds@osdl.org>
203 and Junio C Hamano <gitster@pobox.com>
204
205 Documentation
206 --------------
207 Documentation by Jon Loeliger,
208 David Greaves,
209 Junio C Hamano and the git-list <git@vger.kernel.org>.
210
211 GIT
212 ---
213 Part of the linkgit:git[1] suite