Code

Documentation/git-pull.txt: Add subtitles above included option files
[git.git] / Documentation / git-pull.txt
1 git-pull(1)
2 ===========
4 NAME
5 ----
6 git-pull - Fetch from and merge with another repository or a local branch
9 SYNOPSIS
10 --------
11 'git pull' <options> <repository> <refspec>...
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'.
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 OPTIONS
28 -------
30 Options related to merging
31 ~~~~~~~~~~~~~~~~~~~~~~~~~~
33 include::merge-options.txt[]
35 :git-pull: 1
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.
51 --no-rebase::
52         Override earlier --rebase.
54 Options related to fetching
55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
57 include::fetch-options.txt[]
59 include::pull-fetch-param.txt[]
61 include::urls-remotes.txt[]
63 include::merge-strategies.txt[]
65 DEFAULT BEHAVIOUR
66 -----------------
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`.
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.
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:
88 ------------
89 refs/heads/*:refs/remotes/origin/*
90 ------------
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.
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.
102 If explicit refspecs were given on the command
103 line of `git pull`, they are all merged.
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:
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.
114 . If the refspec is a globbing one, nothing is merged.
116 . Otherwise the remote branch of the first refspec is merged.
119 EXAMPLES
120 --------
122 * Update the remote-tracking branches for the repository
123   you cloned from, then merge one of them into your
124   current branch:
126 ------------------------------------------------
127 $ git pull, git pull origin
128 ------------------------------------------------
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.
134 * Merge into the current branch the remote branch `next`:
136 ------------------------------------------------
137 $ git pull origin next
138 ------------------------------------------------
140 This leaves a copy of `next` temporarily in FETCH_HEAD, but
141 does not update any remote-tracking branches.
143 * Bundle local branch `fixes` and `enhancements` on top of
144   the current branch, making an Octopus merge:
146 ------------------------------------------------
147 $ git pull . fixes enhancements
148 ------------------------------------------------
150 This `git pull .` syntax is equivalent to `git merge`.
152 * Merge local branch `obsolete` into the current branch, using `ours`
153   merge strategy:
155 ------------------------------------------------
156 $ git pull -s ours . obsolete
157 ------------------------------------------------
159 * Merge local branch `maint` into the current branch, but do not make
160   a commit automatically:
162 ------------------------------------------------
163 $ git pull --no-commit . maint
164 ------------------------------------------------
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.
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.
173 * Command line pull of multiple branches from one repository:
175 ------------------------------------------------
176 $ git checkout master
177 $ git fetch origin +pu:pu maint:tmp
178 $ git pull . tmp
179 ------------------------------------------------
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.
185 The `pu` branch will be updated even if it is does not fast-forward;
186 the others will not be.
188 The final command then merges the newly fetched `tmp` into master.
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'.
195 SEE ALSO
196 --------
197 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
200 Author
201 ------
202 Written by Linus Torvalds <torvalds@osdl.org>
203 and Junio C Hamano <gitster@pobox.com>
205 Documentation
206 --------------
207 Documentation by Jon Loeliger,
208 David Greaves,
209 Junio C Hamano and the git-list <git@vger.kernel.org>.
211 GIT
212 ---
213 Part of the linkgit:git[1] suite