Merge branch 'ja/fetch-doc' into maint
[git/dscho.git] / Documentation / git-pull.txt
blobb93201158fa6fda914b6093af5911b7884328838
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`.
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. Using remote-tracking
142 branches, the same can be done by invoking fetch and merge:
144 ------------------------------------------------
145 $ git fetch origin
146 $ git merge origin/next
147 ------------------------------------------------
150 If you tried a pull which resulted in a complex conflicts and
151 would want to start over, you can recover with 'git-reset'.
154 SEE ALSO
155 --------
156 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
159 Author
160 ------
161 Written by Linus Torvalds <torvalds@osdl.org>
162 and Junio C Hamano <gitster@pobox.com>
164 Documentation
165 --------------
166 Documentation by Jon Loeliger,
167 David Greaves,
168 Junio C Hamano and the git-list <git@vger.kernel.org>.
172 Part of the linkgit:git[1] suite