Documentation/git-pull.txt: Add subtitles above included option files
[git/git.git] / Documentation / git-pull.txt
CommitLineData
215a7ad1
JH
1git-pull(1)
2===========
2cf565c5
DG
3
4NAME
5----
c3f0baac 6git-pull - Fetch from and merge with another repository or a local branch
2cf565c5
DG
7
8
9SYNOPSIS
10--------
b1889c36 11'git pull' <options> <repository> <refspec>...
0c04094b 12
2cf565c5
DG
13
14DESCRIPTION
15-----------
ba020ef5 16Runs 'git-fetch' with the given parameters, and calls 'git-merge'
bccf5956 17to merge the retrieved head(s) into the current branch.
ba020ef5 18With `--rebase`, calls 'git-rebase' instead of 'git-merge'.
ab9b3138 19
bccf5956 20Note that you can use `.` (current directory) as the
710c97db
JH
21<repository> to pull from the local repository -- this is useful
22when merging local branches into the current branch.
0c04094b 23
ba020ef5
JN
24Also note that options meant for 'git-pull' itself and underlying
25'git-merge' must be given before the options meant for 'git-fetch'.
93d69d86 26
0c04094b
JH
27OPTIONS
28-------
3f7a9b5a
JA
29
30Options related to merging
31~~~~~~~~~~~~~~~~~~~~~~~~~~
32
93d69d86 33include::merge-options.txt[]
2cf565c5 34
10eb64f5 35:git-pull: 1
37465016 36
3240240f 37--rebase::
c85c7927
JS
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
a288394e
JS
41 to avoid rebasing non-local changes. To make this the default
42 for branch `<name>`, set configuration `branch.<name>.rebase`
43 to `true`.
473d3316 44+
6bfa3c99
JH
45[NOTE]
46This is a potentially _dangerous_ mode of operation.
473d3316
JH
47It rewrites history, which does not bode well when you
48published that history already. Do *not* use this option
49unless you have read linkgit:git-rebase[1] carefully.
cd67e4d4 50
3240240f
SB
51--no-rebase::
52 Override earlier --rebase.
cd67e4d4 53
3f7a9b5a
JA
54Options related to fetching
55~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
a288394e
JS
57include::fetch-options.txt[]
58
59include::pull-fetch-param.txt[]
60
61include::urls-remotes.txt[]
62
63include::merge-strategies.txt[]
64
9e2586ff
JH
65DEFAULT BEHAVIOUR
66-----------------
67
68Often people use `git pull` without giving any parameter.
69Traditionally, this has been equivalent to saying `git pull
70origin`. However, when configuration `branch.<name>.remote` is
71present while on branch `<name>`, that value is used instead of
72`origin`.
73
74In order to determine what URL to use to fetch from, the value
75of the configuration `remote.<origin>.url` is consulted
76and if there is not any such variable, the value on `URL: ` line
77in `$GIT_DIR/remotes/<origin>` file is used.
78
79In order to determine what remote branches to fetch (and
80optionally store in the tracking branches) when the command is
81run without any refspec parameters on the command line, values
82of the configuration variable `remote.<origin>.fetch` are
83consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
84file is consulted and its `Pull: ` lines are used.
85In addition to the refspec formats described in the OPTIONS
86section, you can have a globbing refspec that looks like this:
87
88------------
89refs/heads/*:refs/remotes/origin/*
90------------
91
92A globbing refspec must have a non-empty RHS (i.e. must store
93what were fetched in tracking branches), and its LHS and RHS
94must end with `/*`. The above specifies that all remote
95branches are tracked using tracking branches in
96`refs/remotes/origin/` hierarchy under the same name.
97
98The rule to determine which remote branch to merge after
99fetching is a bit involved, in order not to break backward
100compatibility.
101
102If explicit refspecs were given on the command
103line of `git pull`, they are all merged.
104
105When no refspec was given on the command line, then `git pull`
106uses the refspec from the configuration or
107`$GIT_DIR/remotes/<origin>`. In such cases, the following
108rules 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
37465016
JH
119EXAMPLES
120--------
121
921177f5
CC
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+
130Normally the branch merged in is the HEAD of the remote repository,
131but the choice is determined by the branch.<name>.remote and
132branch.<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+
140This leaves a copy of `next` temporarily in FETCH_HEAD, but
141does 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+
150This `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+
166This can be used when you want to include further changes to the
167merge, or want to write your own merge commit message.
37465016
JH
168+
169You should refrain from abusing this option to sneak substantial
170changes into a merge commit. Small fixups like bumping
171release/version name would be acceptable.
172
921177f5 173* Command line pull of multiple branches from one repository:
bccf5956
JL
174+
175------------------------------------------------
bccf5956 176$ git checkout master
33a59fd0
BF
177$ git fetch origin +pu:pu maint:tmp
178$ git pull . tmp
bccf5956
JL
179------------------------------------------------
180+
921177f5
CC
181This updates (or creates, as necessary) branches `pu` and `tmp` in
182the local repository by fetching from the branches (respectively)
183`pu` and `maint` from the remote repository.
bccf5956 184+
921177f5
CC
185The `pu` branch will be updated even if it is does not fast-forward;
186the others will not be.
bccf5956 187+
33a59fd0 188The final command then merges the newly fetched `tmp` into master.
bccf5956 189
37465016 190
3ae854c3 191If you tried a pull which resulted in a complex conflicts and
ba020ef5 192would want to start over, you can recover with 'git-reset'.
3ae854c3
JH
193
194
fdd08979
JH
195SEE ALSO
196--------
5162e697 197linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
fdd08979
JH
198
199
2cf565c5
DG
200Author
201------
3f971fc4 202Written by Linus Torvalds <torvalds@osdl.org>
59eb68aa 203and Junio C Hamano <gitster@pobox.com>
2cf565c5
DG
204
205Documentation
206--------------
bccf5956
JL
207Documentation by Jon Loeliger,
208David Greaves,
209Junio C Hamano and the git-list <git@vger.kernel.org>.
2cf565c5
DG
210
211GIT
212---
9e1f0a85 213Part of the linkgit:git[1] suite