]>
Commit | Line | Data |
---|---|---|
215a7ad1 JH |
1 | git-pull(1) |
2 | =========== | |
2cf565c5 DG |
3 | |
4 | NAME | |
5 | ---- | |
c3f0baac | 6 | git-pull - Fetch from and merge with another repository or a local branch |
2cf565c5 DG |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
b1889c36 | 11 | 'git pull' <options> <repository> <refspec>... |
0c04094b | 12 | |
2cf565c5 DG |
13 | |
14 | DESCRIPTION | |
15 | ----------- | |
0b444cdb | 16 | Runs 'git fetch' with the given parameters, and calls 'git merge' |
bccf5956 | 17 | to merge the retrieved head(s) into the current branch. |
0b444cdb | 18 | With `--rebase`, calls 'git rebase' instead of 'git merge'. |
ab9b3138 | 19 | |
bccf5956 | 20 | Note that you can use `.` (current directory) as the |
710c97db JH |
21 | <repository> to pull from the local repository -- this is useful |
22 | when merging local branches into the current branch. | |
0c04094b | 23 | |
0b444cdb TR |
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'. | |
93d69d86 | 26 | |
0b444cdb | 27 | *Warning*: Running 'git pull' (actually, the underlying 'git merge') |
e330d8ca TR |
28 | with uncommitted changes is discouraged: while possible, it leaves you |
29 | in a state that is hard to back out of in the case of a conflict. | |
30 | ||
0c04094b JH |
31 | OPTIONS |
32 | ------- | |
3f7a9b5a | 33 | |
409b8d82 TRC |
34 | -q:: |
35 | --quiet:: | |
9839018e TRC |
36 | This is passed to both underlying git-fetch to squelch reporting of |
37 | during transfer, and underlying git-merge to squelch output during | |
38 | merging. | |
409b8d82 TRC |
39 | |
40 | -v:: | |
41 | --verbose:: | |
42 | Pass --verbose to git-fetch and git-merge. | |
43 | ||
3f7a9b5a JA |
44 | Options related to merging |
45 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
46 | ||
93d69d86 | 47 | include::merge-options.txt[] |
2cf565c5 | 48 | |
10eb64f5 | 49 | :git-pull: 1 |
37465016 | 50 | |
3240240f | 51 | --rebase:: |
c85c7927 JS |
52 | Instead of a merge, perform a rebase after fetching. If |
53 | there is a remote ref for the upstream branch, and this branch | |
54 | was rebased since last fetched, the rebase uses that information | |
a288394e JS |
55 | to avoid rebasing non-local changes. To make this the default |
56 | for branch `<name>`, set configuration `branch.<name>.rebase` | |
57 | to `true`. | |
473d3316 | 58 | + |
6bfa3c99 JH |
59 | [NOTE] |
60 | This is a potentially _dangerous_ mode of operation. | |
473d3316 JH |
61 | It rewrites history, which does not bode well when you |
62 | published that history already. Do *not* use this option | |
63 | unless you have read linkgit:git-rebase[1] carefully. | |
cd67e4d4 | 64 | |
3240240f SB |
65 | --no-rebase:: |
66 | Override earlier --rebase. | |
cd67e4d4 | 67 | |
3f7a9b5a JA |
68 | Options related to fetching |
69 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
70 | ||
a288394e JS |
71 | include::fetch-options.txt[] |
72 | ||
73 | include::pull-fetch-param.txt[] | |
74 | ||
75 | include::urls-remotes.txt[] | |
76 | ||
77 | include::merge-strategies.txt[] | |
78 | ||
9e2586ff JH |
79 | DEFAULT BEHAVIOUR |
80 | ----------------- | |
81 | ||
82 | Often people use `git pull` without giving any parameter. | |
83 | Traditionally, this has been equivalent to saying `git pull | |
84 | origin`. However, when configuration `branch.<name>.remote` is | |
85 | present while on branch `<name>`, that value is used instead of | |
86 | `origin`. | |
87 | ||
88 | In order to determine what URL to use to fetch from, the value | |
89 | of the configuration `remote.<origin>.url` is consulted | |
90 | and if there is not any such variable, the value on `URL: ` line | |
91 | in `$GIT_DIR/remotes/<origin>` file is used. | |
92 | ||
93 | In order to determine what remote branches to fetch (and | |
94 | optionally store in the tracking branches) when the command is | |
95 | run without any refspec parameters on the command line, values | |
96 | of the configuration variable `remote.<origin>.fetch` are | |
97 | consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>` | |
98 | file is consulted and its `Pull: ` lines are used. | |
99 | In addition to the refspec formats described in the OPTIONS | |
100 | section, you can have a globbing refspec that looks like this: | |
101 | ||
102 | ------------ | |
103 | refs/heads/*:refs/remotes/origin/* | |
104 | ------------ | |
105 | ||
106 | A globbing refspec must have a non-empty RHS (i.e. must store | |
107 | what were fetched in tracking branches), and its LHS and RHS | |
108 | must end with `/*`. The above specifies that all remote | |
109 | branches are tracked using tracking branches in | |
110 | `refs/remotes/origin/` hierarchy under the same name. | |
111 | ||
112 | The rule to determine which remote branch to merge after | |
113 | fetching is a bit involved, in order not to break backward | |
114 | compatibility. | |
115 | ||
116 | If explicit refspecs were given on the command | |
117 | line of `git pull`, they are all merged. | |
118 | ||
119 | When no refspec was given on the command line, then `git pull` | |
120 | uses the refspec from the configuration or | |
121 | `$GIT_DIR/remotes/<origin>`. In such cases, the following | |
122 | rules apply: | |
123 | ||
124 | . If `branch.<name>.merge` configuration for the current | |
125 | branch `<name>` exists, that is the name of the branch at the | |
126 | remote site that is merged. | |
127 | ||
128 | . If the refspec is a globbing one, nothing is merged. | |
129 | ||
130 | . Otherwise the remote branch of the first refspec is merged. | |
131 | ||
132 | ||
37465016 JH |
133 | EXAMPLES |
134 | -------- | |
135 | ||
921177f5 CC |
136 | * Update the remote-tracking branches for the repository |
137 | you cloned from, then merge one of them into your | |
138 | current branch: | |
139 | + | |
140 | ------------------------------------------------ | |
141 | $ git pull, git pull origin | |
142 | ------------------------------------------------ | |
143 | + | |
144 | Normally the branch merged in is the HEAD of the remote repository, | |
145 | but the choice is determined by the branch.<name>.remote and | |
146 | branch.<name>.merge options; see linkgit:git-config[1] for details. | |
147 | ||
148 | * Merge into the current branch the remote branch `next`: | |
149 | + | |
150 | ------------------------------------------------ | |
151 | $ git pull origin next | |
152 | ------------------------------------------------ | |
153 | + | |
154 | This leaves a copy of `next` temporarily in FETCH_HEAD, but | |
d504f697 CB |
155 | does not update any remote-tracking branches. Using remote-tracking |
156 | branches, the same can be done by invoking fetch and merge: | |
921177f5 CC |
157 | + |
158 | ------------------------------------------------ | |
d504f697 CB |
159 | $ git fetch origin |
160 | $ git merge origin/next | |
921177f5 | 161 | ------------------------------------------------ |
bccf5956 | 162 | |
37465016 | 163 | |
3ae854c3 | 164 | If you tried a pull which resulted in a complex conflicts and |
0b444cdb | 165 | would want to start over, you can recover with 'git reset'. |
3ae854c3 JH |
166 | |
167 | ||
fdd08979 JH |
168 | SEE ALSO |
169 | -------- | |
5162e697 | 170 | linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1] |
fdd08979 JH |
171 | |
172 | ||
2cf565c5 DG |
173 | Author |
174 | ------ | |
3f971fc4 | 175 | Written by Linus Torvalds <torvalds@osdl.org> |
59eb68aa | 176 | and Junio C Hamano <gitster@pobox.com> |
2cf565c5 DG |
177 | |
178 | Documentation | |
179 | -------------- | |
bccf5956 JL |
180 | Documentation by Jon Loeliger, |
181 | David Greaves, | |
182 | Junio C Hamano and the git-list <git@vger.kernel.org>. | |
2cf565c5 DG |
183 | |
184 | GIT | |
185 | --- | |
9e1f0a85 | 186 | Part of the linkgit:git[1] suite |