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