OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / doc / source / en / TortoiseGit / git_doc / git-pull.html.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-pull(1)">\r
5 <articleinfo>\r
6     <title>git-pull(1)</title>\r
7         <indexterm>\r
8                 <primary>git-pull(1)</primary>\r
9         </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-pull - Fetch from and merge with another repository or a local branch</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <simpara><emphasis>git pull</emphasis> &lt;options&gt; &lt;repository&gt; &lt;refspec&gt;&#8230;</simpara>\r
18 </simplesect>\r
19 <simplesect id="_description">\r
20 <title>DESCRIPTION</title>\r
21 <simpara>Runs <emphasis>git-fetch</emphasis> with the given parameters, and calls <emphasis>git-merge</emphasis>\r
22 to merge the retrieved head(s) into the current branch.\r
23 With <literal>--rebase</literal>, calls <emphasis>git-rebase</emphasis> instead of <emphasis>git-merge</emphasis>.</simpara>\r
24 <simpara>Note that you can use <literal>.</literal> (current directory) as the\r
25 &lt;repository&gt; to pull from the local repository&#8201;&#8212;&#8201;this is useful\r
26 when merging local branches into the current branch.</simpara>\r
27 <simpara>Also note that options meant for <emphasis>git-pull</emphasis> itself and underlying\r
28 <emphasis>git-merge</emphasis> must be given before the options meant for <emphasis>git-fetch</emphasis>.</simpara>\r
29 </simplesect>\r
30 <simplesect id="_options">\r
31 <title>OPTIONS</title>\r
32 <variablelist>\r
33 <varlistentry>\r
34 <term>\r
35 -q\r
36 </term>\r
37 <term>\r
38 --quiet\r
39 </term>\r
40 <listitem>\r
41 <simpara>\r
42         Operate quietly.\r
43 </simpara>\r
44 </listitem>\r
45 </varlistentry>\r
46 <varlistentry>\r
47 <term>\r
48 -v\r
49 </term>\r
50 <term>\r
51 --verbose\r
52 </term>\r
53 <listitem>\r
54 <simpara>\r
55         Be verbose.\r
56 </simpara>\r
57 </listitem>\r
58 </varlistentry>\r
59 <varlistentry>\r
60 <term>\r
61 --stat\r
62 </term>\r
63 <listitem>\r
64 <simpara>\r
65         Show a diffstat at the end of the merge. The diffstat is also\r
66         controlled by the configuration option merge.stat.\r
67 </simpara>\r
68 </listitem>\r
69 </varlistentry>\r
70 <varlistentry>\r
71 <term>\r
72 -n\r
73 </term>\r
74 <term>\r
75 --no-stat\r
76 </term>\r
77 <listitem>\r
78 <simpara>\r
79         Do not show a diffstat at the end of the merge.\r
80 </simpara>\r
81 </listitem>\r
82 </varlistentry>\r
83 <varlistentry>\r
84 <term>\r
85 --summary\r
86 </term>\r
87 <term>\r
88 --no-summary\r
89 </term>\r
90 <listitem>\r
91 <simpara>\r
92         Synonyms to --stat and --no-stat; these are deprecated and will be\r
93         removed in the future.\r
94 </simpara>\r
95 </listitem>\r
96 </varlistentry>\r
97 <varlistentry>\r
98 <term>\r
99 --log\r
100 </term>\r
101 <listitem>\r
102 <simpara>\r
103         In addition to branch names, populate the log message with\r
104         one-line descriptions from the actual commits that are being\r
105         merged.\r
106 </simpara>\r
107 </listitem>\r
108 </varlistentry>\r
109 <varlistentry>\r
110 <term>\r
111 --no-log\r
112 </term>\r
113 <listitem>\r
114 <simpara>\r
115         Do not list one-line descriptions from the actual commits being\r
116         merged.\r
117 </simpara>\r
118 </listitem>\r
119 </varlistentry>\r
120 <varlistentry>\r
121 <term>\r
122 --no-commit\r
123 </term>\r
124 <listitem>\r
125 <simpara>\r
126         Perform the merge but pretend the merge failed and do\r
127         not autocommit, to give the user a chance to inspect and\r
128         further tweak the merge result before committing.\r
129 </simpara>\r
130 </listitem>\r
131 </varlistentry>\r
132 <varlistentry>\r
133 <term>\r
134 --commit\r
135 </term>\r
136 <listitem>\r
137 <simpara>\r
138         Perform the merge and commit the result. This option can\r
139         be used to override --no-commit.\r
140 </simpara>\r
141 </listitem>\r
142 </varlistentry>\r
143 <varlistentry>\r
144 <term>\r
145 --squash\r
146 </term>\r
147 <listitem>\r
148 <simpara>\r
149         Produce the working tree and index state as if a real\r
150         merge happened, but do not actually make a commit or\r
151         move the <literal>HEAD</literal>, nor record <literal>$GIT_DIR/MERGE_HEAD</literal> to\r
152         cause the next <literal>git commit</literal> command to create a merge\r
153         commit.  This allows you to create a single commit on\r
154         top of the current branch whose effect is the same as\r
155         merging another branch (or more in case of an octopus).\r
156 </simpara>\r
157 </listitem>\r
158 </varlistentry>\r
159 <varlistentry>\r
160 <term>\r
161 --no-squash\r
162 </term>\r
163 <listitem>\r
164 <simpara>\r
165         Perform the merge and commit the result. This option can\r
166         be used to override --squash.\r
167 </simpara>\r
168 </listitem>\r
169 </varlistentry>\r
170 <varlistentry>\r
171 <term>\r
172 --no-ff\r
173 </term>\r
174 <listitem>\r
175 <simpara>\r
176         Generate a merge commit even if the merge resolved as a\r
177         fast-forward.\r
178 </simpara>\r
179 </listitem>\r
180 </varlistentry>\r
181 <varlistentry>\r
182 <term>\r
183 --ff\r
184 </term>\r
185 <listitem>\r
186 <simpara>\r
187         Do not generate a merge commit if the merge resolved as\r
188         a fast-forward, only update the branch pointer. This is\r
189         the default behavior of git-merge.\r
190 </simpara>\r
191 </listitem>\r
192 </varlistentry>\r
193 <varlistentry>\r
194 <term>\r
195 -s &lt;strategy&gt;\r
196 </term>\r
197 <term>\r
198 --strategy=&lt;strategy&gt;\r
199 </term>\r
200 <listitem>\r
201 <simpara>\r
202         Use the given merge strategy; can be supplied more than\r
203         once to specify them in the order they should be tried.\r
204         If there is no <literal>-s</literal> option, a built-in list of strategies\r
205         is used instead (<emphasis>git-merge-recursive</emphasis> when merging a single\r
206         head, <emphasis>git-merge-octopus</emphasis> otherwise).\r
207 </simpara>\r
208 </listitem>\r
209 </varlistentry>\r
210 </variablelist>\r
211 <variablelist>\r
212 <varlistentry>\r
213 <term>\r
214 --rebase\r
215 </term>\r
216 <listitem>\r
217 <simpara>\r
218         Instead of a merge, perform a rebase after fetching.  If\r
219         there is a remote ref for the upstream branch, and this branch\r
220         was rebased since last fetched, the rebase uses that information\r
221         to avoid rebasing non-local changes. To make this the default\r
222         for branch <literal>&lt;name&gt;</literal>, set configuration <literal>branch.&lt;name&gt;.rebase</literal>\r
223         to <literal>true</literal>.\r
224 </simpara>\r
225 <note><simpara>This is a potentially <emphasis>dangerous</emphasis> mode of operation.\r
226 It rewrites history, which does not bode well when you\r
227 published that history already.  Do <emphasis role="strong">not</emphasis> use this option\r
228 unless you have read <xref linkend="git-rebase(1)"/> carefully.</simpara></note>\r
229 </listitem>\r
230 </varlistentry>\r
231 <varlistentry>\r
232 <term>\r
233 --no-rebase\r
234 </term>\r
235 <listitem>\r
236 <simpara>\r
237         Override earlier --rebase.\r
238 </simpara>\r
239 </listitem>\r
240 </varlistentry>\r
241 <varlistentry>\r
242 <term>\r
243 -q\r
244 </term>\r
245 <term>\r
246 --quiet\r
247 </term>\r
248 <listitem>\r
249 <simpara>\r
250         Pass --quiet to git-fetch-pack and silence any other internally\r
251         used programs.\r
252 </simpara>\r
253 </listitem>\r
254 </varlistentry>\r
255 <varlistentry>\r
256 <term>\r
257 -v\r
258 </term>\r
259 <term>\r
260 --verbose\r
261 </term>\r
262 <listitem>\r
263 <simpara>\r
264         Be verbose.\r
265 </simpara>\r
266 </listitem>\r
267 </varlistentry>\r
268 <varlistentry>\r
269 <term>\r
270 -a\r
271 </term>\r
272 <term>\r
273 --append\r
274 </term>\r
275 <listitem>\r
276 <simpara>\r
277         Append ref names and object names of fetched refs to the\r
278         existing contents of <literal>.git/FETCH_HEAD</literal>.  Without this\r
279         option old data in <literal>.git/FETCH_HEAD</literal> will be overwritten.\r
280 </simpara>\r
281 </listitem>\r
282 </varlistentry>\r
283 <varlistentry>\r
284 <term>\r
285 --upload-pack &lt;upload-pack&gt;\r
286 </term>\r
287 <listitem>\r
288 <simpara>\r
289         When given, and the repository to fetch from is handled\r
290         by <emphasis>git-fetch-pack</emphasis>, <emphasis>--exec=&lt;upload-pack&gt;</emphasis> is passed to\r
291         the command to specify non-default path for the command\r
292         run on the other end.\r
293 </simpara>\r
294 </listitem>\r
295 </varlistentry>\r
296 <varlistentry>\r
297 <term>\r
298 -f\r
299 </term>\r
300 <term>\r
301 --force\r
302 </term>\r
303 <listitem>\r
304 <simpara>\r
305         When <emphasis>git-fetch</emphasis> is used with <literal>&lt;rbranch&gt;:&lt;lbranch&gt;</literal>\r
306         refspec, it refuses to update the local branch\r
307         <literal>&lt;lbranch&gt;</literal> unless the remote branch <literal>&lt;rbranch&gt;</literal> it\r
308         fetches is a descendant of <literal>&lt;lbranch&gt;</literal>.  This option\r
309         overrides that check.\r
310 </simpara>\r
311 </listitem>\r
312 </varlistentry>\r
313 <varlistentry>\r
314 <term>\r
315 --no-tags\r
316 </term>\r
317 <listitem>\r
318 <simpara>\r
319         By default, tags that point at objects that are downloaded\r
320         from the remote repository are fetched and stored locally.\r
321         This option disables this automatic tag following.\r
322 </simpara>\r
323 </listitem>\r
324 </varlistentry>\r
325 <varlistentry>\r
326 <term>\r
327 -t\r
328 </term>\r
329 <term>\r
330 --tags\r
331 </term>\r
332 <listitem>\r
333 <simpara>\r
334         Most of the tags are fetched automatically as branch\r
335         heads are downloaded, but tags that do not point at\r
336         objects reachable from the branch heads that are being\r
337         tracked will not be fetched by this mechanism.  This\r
338         flag lets all tags and their associated objects be\r
339         downloaded.\r
340 </simpara>\r
341 </listitem>\r
342 </varlistentry>\r
343 <varlistentry>\r
344 <term>\r
345 -k\r
346 </term>\r
347 <term>\r
348 --keep\r
349 </term>\r
350 <listitem>\r
351 <simpara>\r
352         Keep downloaded pack.\r
353 </simpara>\r
354 </listitem>\r
355 </varlistentry>\r
356 <varlistentry>\r
357 <term>\r
358 -u\r
359 </term>\r
360 <term>\r
361 --update-head-ok\r
362 </term>\r
363 <listitem>\r
364 <simpara>\r
365         By default <emphasis>git-fetch</emphasis> refuses to update the head which\r
366         corresponds to the current branch.  This flag disables the\r
367         check.  This is purely for the internal use for <emphasis>git-pull</emphasis>\r
368         to communicate with <emphasis>git-fetch</emphasis>, and unless you are\r
369         implementing your own Porcelain you are not supposed to\r
370         use it.\r
371 </simpara>\r
372 </listitem>\r
373 </varlistentry>\r
374 <varlistentry>\r
375 <term>\r
376 --depth=&lt;depth&gt;\r
377 </term>\r
378 <listitem>\r
379 <simpara>\r
380         Deepen the history of a <emphasis>shallow</emphasis> repository created by\r
381         <literal>git clone</literal> with <literal>--depth=&lt;depth&gt;</literal> option (see <xref linkend="git-clone(1)"/>)\r
382         by the specified number of commits.\r
383 </simpara>\r
384 </listitem>\r
385 </varlistentry>\r
386 <varlistentry>\r
387 <term>\r
388 &lt;repository&gt;\r
389 </term>\r
390 <listitem>\r
391 <simpara>\r
392         The "remote" repository that is the source of a fetch\r
393         or pull operation.  This parameter can be either a URL\r
394         (see the section <link linkend="URLS">GIT URLS</link> below) or the name\r
395         of a remote (see the section <link linkend="REMOTES">REMOTES</link> below).\r
396 </simpara>\r
397 </listitem>\r
398 </varlistentry>\r
399 <varlistentry>\r
400 <term>\r
401 &lt;refspec&gt;\r
402 </term>\r
403 <listitem>\r
404 <simpara>\r
405         The format of a &lt;refspec&gt; parameter is an optional plus\r
406         <literal>&#43;</literal>, followed by the source ref &lt;src&gt;, followed\r
407         by a colon <literal>:</literal>, followed by the destination ref &lt;dst&gt;.\r
408 </simpara>\r
409 <simpara>The remote ref that matches &lt;src&gt;\r
410 is fetched, and if &lt;dst&gt; is not empty string, the local\r
411 ref that matches it is fast forwarded using &lt;src&gt;.\r
412 If the optional plus <literal>+</literal> is used, the local ref\r
413 is updated even if it does not result in a fast forward\r
414 update.</simpara>\r
415 <note><simpara>If the remote branch from which you want to pull is\r
416 modified in non-linear ways such as being rewound and\r
417 rebased frequently, then a pull will attempt a merge with\r
418 an older version of itself, likely conflict, and fail.\r
419 It is under these conditions that you would want to use\r
420 the <literal>+</literal> sign to indicate non-fast-forward updates will\r
421 be needed.  There is currently no easy way to determine\r
422 or declare that a branch will be made available in a\r
423 repository with this behavior; the pulling user simply\r
424 must know this is the expected usage pattern for a branch.</simpara></note>\r
425 <note><simpara>You never do your own development on branches that appear\r
426 on the right hand side of a &lt;refspec&gt; colon on <literal>Pull:</literal> lines;\r
427 they are to be updated by <emphasis>git-fetch</emphasis>.  If you intend to do\r
428 development derived from a remote branch <literal>B</literal>, have a <literal>Pull:</literal>\r
429 line to track it (i.e. <literal>Pull: B:remote-B</literal>), and have a separate\r
430 branch <literal>my-B</literal> to do your development on top of it.  The latter\r
431 is created by <literal>git branch my-B remote-B</literal> (or its equivalent <literal>git\r
432 checkout -b my-B remote-B</literal>).  Run <literal>git fetch</literal> to keep track of\r
433 the progress of the remote side, and when you see something new\r
434 on the remote branch, merge it into your development branch with\r
435 <literal>git pull . remote-B</literal>, while you are on <literal>my-B</literal> branch.</simpara></note>\r
436 <note><simpara>There is a difference between listing multiple &lt;refspec&gt;\r
437 directly on <emphasis>git-pull</emphasis> command line and having multiple\r
438 <literal>Pull:</literal> &lt;refspec&gt; lines for a &lt;repository&gt; and running\r
439 <emphasis>git-pull</emphasis> command without any explicit &lt;refspec&gt; parameters.\r
440 &lt;refspec&gt; listed explicitly on the command line are always\r
441 merged into the current branch after fetching.  In other words,\r
442 if you list more than one remote refs, you would be making\r
443 an Octopus.  While <emphasis>git-pull</emphasis> run without any explicit &lt;refspec&gt;\r
444 parameter takes default &lt;refspec&gt;s from <literal>Pull:</literal> lines, it\r
445 merges only the first &lt;refspec&gt; found into the current branch,\r
446 after fetching all the remote refs.  This is because making an\r
447 Octopus from remote refs is rarely done, while keeping track\r
448 of multiple remote heads in one-go by fetching more than one\r
449 is often useful.</simpara></note>\r
450 <simpara>Some short-cut notations are also supported.</simpara>\r
451 <itemizedlist>\r
452 <listitem>\r
453 <simpara>\r
454 <literal>tag &lt;tag&gt;</literal> means the same as <literal>refs/tags/&lt;tag&gt;:refs/tags/&lt;tag&gt;</literal>;\r
455   it requests fetching everything up to the given tag.\r
456 </simpara>\r
457 </listitem>\r
458 <listitem>\r
459 <simpara>\r
460 A parameter &lt;ref&gt; without a colon is equivalent to\r
461   &lt;ref&gt;: when pulling/fetching, so it merges &lt;ref&gt; into the current\r
462   branch without storing the remote branch anywhere locally\r
463 </simpara>\r
464 </listitem>\r
465 </itemizedlist>\r
466 </listitem>\r
467 </varlistentry>\r
468 </variablelist>\r
469 </simplesect>\r
470 <simplesect id="_git_urls_anchor_id_urls_xreflabel_urls">\r
471 <title>GIT URLS<anchor id="URLS" xreflabel="[URLS]"/></title>\r
472 <simpara>One of the following notations can be used\r
473 to name the remote repository:</simpara>\r
474 <informalexample>\r
475 <itemizedlist>\r
476 <listitem>\r
477 <simpara>\r
478 rsync://host.xz/path/to/repo.git/\r
479 </simpara>\r
480 </listitem>\r
481 <listitem>\r
482 <simpara>\r
483 <ulink url="http://host.xz&#91;:port&#93;/path/to/repo.git/">http://host.xz&#91;:port&#93;/path/to/repo.git/</ulink>\r
484 </simpara>\r
485 </listitem>\r
486 <listitem>\r
487 <simpara>\r
488 <ulink url="https://host.xz&#91;:port&#93;/path/to/repo.git/">https://host.xz&#91;:port&#93;/path/to/repo.git/</ulink>\r
489 </simpara>\r
490 </listitem>\r
491 <listitem>\r
492 <simpara>\r
493 git://host.xz&#91;:port&#93;/path/to/repo.git/\r
494 </simpara>\r
495 </listitem>\r
496 <listitem>\r
497 <simpara>\r
498 git://host.xz&#91;:port&#93;/~user/path/to/repo.git/\r
499 </simpara>\r
500 </listitem>\r
501 <listitem>\r
502 <simpara>\r
503 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/\r
504 </simpara>\r
505 </listitem>\r
506 <listitem>\r
507 <simpara>\r
508 ssh://&#91;user@&#93;host.xz/path/to/repo.git/\r
509 </simpara>\r
510 </listitem>\r
511 <listitem>\r
512 <simpara>\r
513 ssh://&#91;user@&#93;host.xz/~user/path/to/repo.git/\r
514 </simpara>\r
515 </listitem>\r
516 <listitem>\r
517 <simpara>\r
518 ssh://&#91;user@&#93;host.xz/~/path/to/repo.git\r
519 </simpara>\r
520 </listitem>\r
521 </itemizedlist>\r
522 </informalexample>\r
523 <simpara>SSH is the default transport protocol over the network.  You can\r
524 optionally specify which user to log-in as, and an alternate,\r
525 scp-like syntax is also supported.  Both syntaxes support\r
526 username expansion, as does the native git protocol, but\r
527 only the former supports port specification. The following\r
528 three are identical to the last three above, respectively:</simpara>\r
529 <informalexample>\r
530 <itemizedlist>\r
531 <listitem>\r
532 <simpara>\r
533 &#91;user@&#93;host.xz:/path/to/repo.git/\r
534 </simpara>\r
535 </listitem>\r
536 <listitem>\r
537 <simpara>\r
538 &#91;user@&#93;host.xz:~user/path/to/repo.git/\r
539 </simpara>\r
540 </listitem>\r
541 <listitem>\r
542 <simpara>\r
543 &#91;user@&#93;host.xz:path/to/repo.git\r
544 </simpara>\r
545 </listitem>\r
546 </itemizedlist>\r
547 </informalexample>\r
548 <simpara>To sync with a local directory, you can use:</simpara>\r
549 <informalexample>\r
550 <itemizedlist>\r
551 <listitem>\r
552 <simpara>\r
553 /path/to/repo.git/\r
554 </simpara>\r
555 </listitem>\r
556 <listitem>\r
557 <simpara>\r
558 <ulink url="file:///path/to/repo.git/">file:///path/to/repo.git/</ulink>\r
559 </simpara>\r
560 </listitem>\r
561 </itemizedlist>\r
562 </informalexample>\r
563 <simpara>They are mostly equivalent, except when cloning.  See\r
564 <xref linkend="git-clone(1)"/> for details.</simpara>\r
565 <simpara>If there are a large number of similarly-named remote repositories and\r
566 you want to use a different format for them (such that the URLs you\r
567 use will be rewritten into URLs that work), you can create a\r
568 configuration section of the form:</simpara>\r
569 <literallayout>        [url "&lt;actual url base&gt;"]\r
570                 insteadOf = &lt;other url base&gt;</literallayout>\r
571 <simpara>For example, with this:</simpara>\r
572 <literallayout>        [url "git://git.host.xz/"]\r
573                 insteadOf = host.xz:/path/to/\r
574                 insteadOf = work:</literallayout>\r
575 <simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be\r
576 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>\r
577 </simplesect>\r
578 <simplesect id="_remotes_anchor_id_remotes_xreflabel_remotes">\r
579 <title>REMOTES<anchor id="REMOTES" xreflabel="[REMOTES]"/></title>\r
580 <simpara>The name of one of the following can be used instead\r
581 of a URL as <literal>&lt;repository&gt;</literal> argument:</simpara>\r
582 <itemizedlist>\r
583 <listitem>\r
584 <simpara>\r
585 a remote in the git configuration file: <literal>$GIT_DIR/config</literal>,\r
586 </simpara>\r
587 </listitem>\r
588 <listitem>\r
589 <simpara>\r
590 a file in the <literal>$GIT_DIR/remotes</literal> directory, or\r
591 </simpara>\r
592 </listitem>\r
593 <listitem>\r
594 <simpara>\r
595 a file in the <literal>$GIT_DIR/branches</literal> directory.\r
596 </simpara>\r
597 </listitem>\r
598 </itemizedlist>\r
599 <simpara>All of these also allow you to omit the refspec from the command line\r
600 because they each contain a refspec which git will use by default.</simpara>\r
601 <simplesect id="_named_remote_in_configuration_file">\r
602 <title>Named remote in configuration file</title>\r
603 <simpara>You can choose to provide the name of a remote which you had previously\r
604 configured using <xref linkend="git-remote(1)"/>, <xref linkend="git-config(1)"/>\r
605 or even by a manual edit to the <literal>$GIT_DIR/config</literal> file.  The URL of\r
606 this remote will be used to access the repository.  The refspec\r
607 of this remote will be used by default when you do\r
608 not provide a refspec on the command line.  The entry in the\r
609 config file would appear like this:</simpara>\r
610 <literallayout>        [remote "&lt;name&gt;"]\r
611                 url = &lt;url&gt;\r
612                 push = &lt;refspec&gt;\r
613                 fetch = &lt;refspec&gt;</literallayout>\r
614 </simplesect>\r
615 <simplesect id="_named_file_in_literal_git_dir_remotes_literal">\r
616 <title>Named file in <literal>$GIT_DIR/remotes</literal></title>\r
617 <simpara>You can choose to provide the name of a\r
618 file in <literal>$GIT_DIR/remotes</literal>.  The URL\r
619 in this file will be used to access the repository.  The refspec\r
620 in this file will be used as default when you do not\r
621 provide a refspec on the command line.  This file should have the\r
622 following format:</simpara>\r
623 <literallayout>        URL: one of the above URL format\r
624         Push: &lt;refspec&gt;\r
625         Pull: &lt;refspec&gt;</literallayout>\r
626 <simpara><literal>Push:</literal> lines are used by <emphasis>git-push</emphasis> and\r
627 <literal>Pull:</literal> lines are used by <emphasis>git-pull</emphasis> and <emphasis>git-fetch</emphasis>.\r
628 Multiple <literal>Push:</literal> and <literal>Pull:</literal> lines may\r
629 be specified for additional branch mappings.</simpara>\r
630 </simplesect>\r
631 <simplesect id="_named_file_in_literal_git_dir_branches_literal">\r
632 <title>Named file in <literal>$GIT_DIR/branches</literal></title>\r
633 <simpara>You can choose to provide the name of a\r
634 file in <literal>$GIT_DIR/branches</literal>.\r
635 The URL in this file will be used to access the repository.\r
636 This file should have the following format:</simpara>\r
637 <literallayout>        &lt;url&gt;#&lt;head&gt;</literallayout>\r
638 <simpara><literal>&lt;url&gt;</literal> is required; <literal>#&lt;head&gt;</literal> is optional.</simpara>\r
639 <simpara>Depending on the operation, git will use one of the following\r
640 refspecs, if you don&#8217;t provide one on the command line.\r
641 <literal>&lt;branch&gt;</literal> is the name of this file in <literal>$GIT_DIR/branches</literal> and\r
642 <literal>&lt;head&gt;</literal> defaults to <literal>master</literal>.</simpara>\r
643 <simpara>git fetch uses:</simpara>\r
644 <literallayout>        refs/heads/&lt;head&gt;:refs/heads/&lt;branch&gt;</literallayout>\r
645 <simpara>git push uses:</simpara>\r
646 <literallayout>        HEAD:refs/heads/&lt;head&gt;</literallayout>\r
647 </simplesect>\r
648 </simplesect>\r
649 <simplesect id="_merge_strategies">\r
650 <title>MERGE STRATEGIES</title>\r
651 <variablelist>\r
652 <varlistentry>\r
653 <term>\r
654 resolve\r
655 </term>\r
656 <listitem>\r
657 <simpara>\r
658         This can only resolve two heads (i.e. the current branch\r
659         and another branch you pulled from) using 3-way merge\r
660         algorithm.  It tries to carefully detect criss-cross\r
661         merge ambiguities and is considered generally safe and\r
662         fast.\r
663 </simpara>\r
664 </listitem>\r
665 </varlistentry>\r
666 <varlistentry>\r
667 <term>\r
668 recursive\r
669 </term>\r
670 <listitem>\r
671 <simpara>\r
672         This can only resolve two heads using 3-way merge\r
673         algorithm.  When there are more than one common\r
674         ancestors that can be used for 3-way merge, it creates a\r
675         merged tree of the common ancestors and uses that as\r
676         the reference tree for the 3-way merge.  This has been\r
677         reported to result in fewer merge conflicts without\r
678         causing mis-merges by tests done on actual merge commits\r
679         taken from Linux 2.6 kernel development history.\r
680         Additionally this can detect and handle merges involving\r
681         renames.  This is the default merge strategy when\r
682         pulling or merging one branch.\r
683 </simpara>\r
684 </listitem>\r
685 </varlistentry>\r
686 <varlistentry>\r
687 <term>\r
688 octopus\r
689 </term>\r
690 <listitem>\r
691 <simpara>\r
692         This resolves more than two-head case, but refuses to do\r
693         complex merge that needs manual resolution.  It is\r
694         primarily meant to be used for bundling topic branch\r
695         heads together.  This is the default merge strategy when\r
696         pulling or merging more than one branches.\r
697 </simpara>\r
698 </listitem>\r
699 </varlistentry>\r
700 <varlistentry>\r
701 <term>\r
702 ours\r
703 </term>\r
704 <listitem>\r
705 <simpara>\r
706         This resolves any number of heads, but the result of the\r
707         merge is always the current branch head.  It is meant to\r
708         be used to supersede old development history of side\r
709         branches.\r
710 </simpara>\r
711 </listitem>\r
712 </varlistentry>\r
713 <varlistentry>\r
714 <term>\r
715 subtree\r
716 </term>\r
717 <listitem>\r
718 <simpara>\r
719         This is a modified recursive strategy. When merging trees A and\r
720         B, if B corresponds to a subtree of A, B is first adjusted to\r
721         match the tree structure of A, instead of reading the trees at\r
722         the same level. This adjustment is also done to the common\r
723         ancestor tree.\r
724 </simpara>\r
725 </listitem>\r
726 </varlistentry>\r
727 </variablelist>\r
728 </simplesect>\r
729 <simplesect id="_default_behaviour">\r
730 <title>DEFAULT BEHAVIOUR</title>\r
731 <simpara>Often people use <literal>git pull</literal> without giving any parameter.\r
732 Traditionally, this has been equivalent to saying <literal>git pull\r
733 origin</literal>.  However, when configuration <literal>branch.&lt;name&gt;.remote</literal> is\r
734 present while on branch <literal>&lt;name&gt;</literal>, that value is used instead of\r
735 <literal>origin</literal>.</simpara>\r
736 <simpara>In order to determine what URL to use to fetch from, the value\r
737 of the configuration <literal>remote.&lt;origin&gt;.url</literal> is consulted\r
738 and if there is not any such variable, the value on <literal>URL: ` line\r
739 in `$GIT_DIR/remotes/&lt;origin&gt;</literal> file is used.</simpara>\r
740 <simpara>In order to determine what remote branches to fetch (and\r
741 optionally store in the tracking branches) when the command is\r
742 run without any refspec parameters on the command line, values\r
743 of the configuration variable <literal>remote.&lt;origin&gt;.fetch</literal> are\r
744 consulted, and if there aren&#8217;t any, <literal>$GIT_DIR/remotes/&lt;origin&gt;</literal>\r
745 file is consulted and its `Pull: ` lines are used.\r
746 In addition to the refspec formats described in the OPTIONS\r
747 section, you can have a globbing refspec that looks like this:</simpara>\r
748 <literallayout>refs/heads/*:refs/remotes/origin/*</literallayout>\r
749 <simpara>A globbing refspec must have a non-empty RHS (i.e. must store\r
750 what were fetched in tracking branches), and its LHS and RHS\r
751 must end with <literal>/*</literal>.  The above specifies that all remote\r
752 branches are tracked using tracking branches in\r
753 <literal>refs/remotes/origin/</literal> hierarchy under the same name.</simpara>\r
754 <simpara>The rule to determine which remote branch to merge after\r
755 fetching is a bit involved, in order not to break backward\r
756 compatibility.</simpara>\r
757 <simpara>If explicit refspecs were given on the command\r
758 line of <literal>git pull</literal>, they are all merged.</simpara>\r
759 <simpara>When no refspec was given on the command line, then <literal>git pull</literal>\r
760 uses the refspec from the configuration or\r
761 <literal>$GIT_DIR/remotes/&lt;origin&gt;</literal>.  In such cases, the following\r
762 rules apply:</simpara>\r
763 <orderedlist numeration="arabic">\r
764 <listitem>\r
765 <simpara>\r
766 If <literal>branch.&lt;name&gt;.merge</literal> configuration for the current\r
767   branch <literal>&lt;name&gt;</literal> exists, that is the name of the branch at the\r
768   remote site that is merged.\r
769 </simpara>\r
770 </listitem>\r
771 <listitem>\r
772 <simpara>\r
773 If the refspec is a globbing one, nothing is merged.\r
774 </simpara>\r
775 </listitem>\r
776 <listitem>\r
777 <simpara>\r
778 Otherwise the remote branch of the first refspec is merged.\r
779 </simpara>\r
780 </listitem>\r
781 </orderedlist>\r
782 </simplesect>\r
783 <simplesect id="_examples">\r
784 <title>EXAMPLES</title>\r
785 <itemizedlist>\r
786 <listitem>\r
787 <simpara>\r
788 Update the remote-tracking branches for the repository\r
789   you cloned from, then merge one of them into your\r
790   current branch:\r
791 </simpara>\r
792 <literallayout>$ git pull, git pull origin</literallayout>\r
793 <simpara>Normally the branch merged in is the HEAD of the remote repository,\r
794 but the choice is determined by the branch.&lt;name&gt;.remote and\r
795 branch.&lt;name&gt;.merge options; see <xref linkend="git-config(1)"/> for details.</simpara>\r
796 </listitem>\r
797 <listitem>\r
798 <simpara>\r
799 Merge into the current branch the remote branch <literal>next</literal>:\r
800 </simpara>\r
801 <literallayout>$ git pull origin next</literallayout>\r
802 <simpara>This leaves a copy of <literal>next</literal> temporarily in FETCH_HEAD, but\r
803 does not update any remote-tracking branches.</simpara>\r
804 </listitem>\r
805 <listitem>\r
806 <simpara>\r
807 Bundle local branch <literal>fixes</literal> and <literal>enhancements</literal> on top of\r
808   the current branch, making an Octopus merge:\r
809 </simpara>\r
810 <literallayout>$ git pull . fixes enhancements</literallayout>\r
811 <simpara>This <literal>git pull .</literal> syntax is equivalent to <literal>git merge</literal>.</simpara>\r
812 </listitem>\r
813 <listitem>\r
814 <simpara>\r
815 Merge local branch <literal>obsolete</literal> into the current branch, using <literal>ours</literal>\r
816   merge strategy:\r
817 </simpara>\r
818 <literallayout>$ git pull -s ours . obsolete</literallayout>\r
819 </listitem>\r
820 <listitem>\r
821 <simpara>\r
822 Merge local branch <literal>maint</literal> into the current branch, but do not make\r
823   a commit automatically:\r
824 </simpara>\r
825 <literallayout>$ git pull --no-commit . maint</literallayout>\r
826 <simpara>This can be used when you want to include further changes to the\r
827 merge, or want to write your own merge commit message.</simpara>\r
828 <simpara>You should refrain from abusing this option to sneak substantial\r
829 changes into a merge commit.  Small fixups like bumping\r
830 release/version name would be acceptable.</simpara>\r
831 </listitem>\r
832 <listitem>\r
833 <simpara>\r
834 Command line pull of multiple branches from one repository:\r
835 </simpara>\r
836 <literallayout>$ git checkout master\r
837 $ git fetch origin +pu:pu maint:tmp\r
838 $ git pull . tmp</literallayout>\r
839 <simpara>This updates (or creates, as necessary) branches <literal>pu</literal> and <literal>tmp</literal> in\r
840 the local repository by fetching from the branches (respectively)\r
841 <literal>pu</literal> and <literal>maint</literal> from the remote repository.</simpara>\r
842 <simpara>The <literal>pu</literal> branch will be updated even if it is does not fast-forward;\r
843 the others will not be.</simpara>\r
844 <simpara>The final command then merges the newly fetched <literal>tmp</literal> into master.</simpara>\r
845 </listitem>\r
846 </itemizedlist>\r
847 <simpara>If you tried a pull which resulted in a complex conflicts and\r
848 would want to start over, you can recover with <emphasis>git-reset</emphasis>.</simpara>\r
849 </simplesect>\r
850 <simplesect id="_see_also">\r
851 <title>SEE ALSO</title>\r
852 <simpara><xref linkend="git-fetch(1)"/>, <xref linkend="git-merge(1)"/>, <xref linkend="git-config(1)"/></simpara>\r
853 </simplesect>\r
854 <simplesect id="_author">\r
855 <title>Author</title>\r
856 <simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;\r
857 and Junio C Hamano &lt;<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>&gt;</simpara>\r
858 </simplesect>\r
859 <simplesect id="_documentation">\r
860 <title>Documentation</title>\r
861 <simpara>Documentation by Jon Loeliger,\r
862 David Greaves,\r
863 Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>\r
864 </simplesect>\r
865 <simplesect id="_git">\r
866 <title>GIT</title>\r
867 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>\r
868 </simplesect>\r
869 </article>\r