]>
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 | ----------- | |
bccf5956 JL |
16 | Runs `git-fetch` with the given parameters, and calls `git-merge` |
17 | to merge the retrieved head(s) into the current branch. | |
a288394e | 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 | |
5b10a3c1 JH |
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 | |
0c04094b JH |
27 | OPTIONS |
28 | ------- | |
93d69d86 | 29 | include::merge-options.txt[] |
2cf565c5 | 30 | |
10eb64f5 | 31 | :git-pull: 1 |
37465016 | 32 | |
3240240f | 33 | --rebase:: |
c85c7927 JS |
34 | Instead of a merge, perform a rebase after fetching. If |
35 | there is a remote ref for the upstream branch, and this branch | |
36 | was rebased since last fetched, the rebase uses that information | |
a288394e JS |
37 | to avoid rebasing non-local changes. To make this the default |
38 | for branch `<name>`, set configuration `branch.<name>.rebase` | |
39 | to `true`. | |
473d3316 | 40 | + |
6bfa3c99 JH |
41 | [NOTE] |
42 | This is a potentially _dangerous_ mode of operation. | |
473d3316 JH |
43 | It rewrites history, which does not bode well when you |
44 | published that history already. Do *not* use this option | |
45 | unless you have read linkgit:git-rebase[1] carefully. | |
cd67e4d4 | 46 | |
3240240f SB |
47 | --no-rebase:: |
48 | Override earlier --rebase. | |
cd67e4d4 | 49 | |
a288394e JS |
50 | include::fetch-options.txt[] |
51 | ||
52 | include::pull-fetch-param.txt[] | |
53 | ||
54 | include::urls-remotes.txt[] | |
55 | ||
56 | include::merge-strategies.txt[] | |
57 | ||
9e2586ff JH |
58 | DEFAULT BEHAVIOUR |
59 | ----------------- | |
60 | ||
61 | Often people use `git pull` without giving any parameter. | |
62 | Traditionally, this has been equivalent to saying `git pull | |
63 | origin`. However, when configuration `branch.<name>.remote` is | |
64 | present while on branch `<name>`, that value is used instead of | |
65 | `origin`. | |
66 | ||
67 | In order to determine what URL to use to fetch from, the value | |
68 | of the configuration `remote.<origin>.url` is consulted | |
69 | and if there is not any such variable, the value on `URL: ` line | |
70 | in `$GIT_DIR/remotes/<origin>` file is used. | |
71 | ||
72 | In order to determine what remote branches to fetch (and | |
73 | optionally store in the tracking branches) when the command is | |
74 | run without any refspec parameters on the command line, values | |
75 | of the configuration variable `remote.<origin>.fetch` are | |
76 | consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>` | |
77 | file is consulted and its `Pull: ` lines are used. | |
78 | In addition to the refspec formats described in the OPTIONS | |
79 | section, you can have a globbing refspec that looks like this: | |
80 | ||
81 | ------------ | |
82 | refs/heads/*:refs/remotes/origin/* | |
83 | ------------ | |
84 | ||
85 | A globbing refspec must have a non-empty RHS (i.e. must store | |
86 | what were fetched in tracking branches), and its LHS and RHS | |
87 | must end with `/*`. The above specifies that all remote | |
88 | branches are tracked using tracking branches in | |
89 | `refs/remotes/origin/` hierarchy under the same name. | |
90 | ||
91 | The rule to determine which remote branch to merge after | |
92 | fetching is a bit involved, in order not to break backward | |
93 | compatibility. | |
94 | ||
95 | If explicit refspecs were given on the command | |
96 | line of `git pull`, they are all merged. | |
97 | ||
98 | When no refspec was given on the command line, then `git pull` | |
99 | uses the refspec from the configuration or | |
100 | `$GIT_DIR/remotes/<origin>`. In such cases, the following | |
101 | rules apply: | |
102 | ||
103 | . If `branch.<name>.merge` configuration for the current | |
104 | branch `<name>` exists, that is the name of the branch at the | |
105 | remote site that is merged. | |
106 | ||
107 | . If the refspec is a globbing one, nothing is merged. | |
108 | ||
109 | . Otherwise the remote branch of the first refspec is merged. | |
110 | ||
111 | ||
37465016 JH |
112 | EXAMPLES |
113 | -------- | |
114 | ||
921177f5 CC |
115 | * Update the remote-tracking branches for the repository |
116 | you cloned from, then merge one of them into your | |
117 | current branch: | |
118 | + | |
119 | ------------------------------------------------ | |
120 | $ git pull, git pull origin | |
121 | ------------------------------------------------ | |
122 | + | |
123 | Normally the branch merged in is the HEAD of the remote repository, | |
124 | but the choice is determined by the branch.<name>.remote and | |
125 | branch.<name>.merge options; see linkgit:git-config[1] for details. | |
126 | ||
127 | * Merge into the current branch the remote branch `next`: | |
128 | + | |
129 | ------------------------------------------------ | |
130 | $ git pull origin next | |
131 | ------------------------------------------------ | |
132 | + | |
133 | This leaves a copy of `next` temporarily in FETCH_HEAD, but | |
134 | does not update any remote-tracking branches. | |
135 | ||
136 | * Bundle local branch `fixes` and `enhancements` on top of | |
137 | the current branch, making an Octopus merge: | |
138 | + | |
139 | ------------------------------------------------ | |
140 | $ git pull . fixes enhancements | |
141 | ------------------------------------------------ | |
142 | + | |
143 | This `git pull .` syntax is equivalent to `git merge`. | |
144 | ||
145 | * Merge local branch `obsolete` into the current branch, using `ours` | |
146 | merge strategy: | |
147 | + | |
148 | ------------------------------------------------ | |
149 | $ git pull -s ours . obsolete | |
150 | ------------------------------------------------ | |
151 | ||
152 | * Merge local branch `maint` into the current branch, but do not make | |
153 | a commit automatically: | |
154 | + | |
155 | ------------------------------------------------ | |
156 | $ git pull --no-commit . maint | |
157 | ------------------------------------------------ | |
158 | + | |
159 | This can be used when you want to include further changes to the | |
160 | merge, or want to write your own merge commit message. | |
37465016 JH |
161 | + |
162 | You should refrain from abusing this option to sneak substantial | |
163 | changes into a merge commit. Small fixups like bumping | |
164 | release/version name would be acceptable. | |
165 | ||
921177f5 | 166 | * Command line pull of multiple branches from one repository: |
bccf5956 JL |
167 | + |
168 | ------------------------------------------------ | |
bccf5956 | 169 | $ git checkout master |
33a59fd0 BF |
170 | $ git fetch origin +pu:pu maint:tmp |
171 | $ git pull . tmp | |
bccf5956 JL |
172 | ------------------------------------------------ |
173 | + | |
921177f5 CC |
174 | This updates (or creates, as necessary) branches `pu` and `tmp` in |
175 | the local repository by fetching from the branches (respectively) | |
176 | `pu` and `maint` from the remote repository. | |
bccf5956 | 177 | + |
921177f5 CC |
178 | The `pu` branch will be updated even if it is does not fast-forward; |
179 | the others will not be. | |
bccf5956 | 180 | + |
33a59fd0 | 181 | The final command then merges the newly fetched `tmp` into master. |
bccf5956 | 182 | |
37465016 | 183 | |
3ae854c3 | 184 | If you tried a pull which resulted in a complex conflicts and |
483bc4f0 | 185 | would want to start over, you can recover with `git-reset`. |
3ae854c3 JH |
186 | |
187 | ||
fdd08979 JH |
188 | SEE ALSO |
189 | -------- | |
5162e697 | 190 | linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1] |
fdd08979 JH |
191 | |
192 | ||
2cf565c5 DG |
193 | Author |
194 | ------ | |
3f971fc4 JH |
195 | Written by Linus Torvalds <torvalds@osdl.org> |
196 | and Junio C Hamano <junkio@cox.net> | |
2cf565c5 DG |
197 | |
198 | Documentation | |
199 | -------------- | |
bccf5956 JL |
200 | Documentation by Jon Loeliger, |
201 | David Greaves, | |
202 | Junio C Hamano and the git-list <git@vger.kernel.org>. | |
2cf565c5 DG |
203 | |
204 | GIT | |
205 | --- | |
9e1f0a85 | 206 | Part of the linkgit:git[1] suite |