Skip to content

Commit d504f69

Browse files
Clemens Buchachergitster
authored andcommitted
modernize fetch/merge/pull examples
The "git pull" documentation has examples which follow an outdated style. Update the examples to use "git merge" where appropriate and move the examples to the corresponding manpages. Furthermore, - show that pull is equivalent to fetch and merge, which is still a frequently asked question, - explain the default fetch refspec. Signed-off-by: Clemens Buchacher <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78d553b commit d504f69

File tree

3 files changed

+66
-45
lines changed

3 files changed

+66
-45
lines changed

Documentation/git-fetch.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,35 @@ include::pull-fetch-param.txt[]
3737

3838
include::urls-remotes.txt[]
3939

40+
41+
EXAMPLES
42+
--------
43+
44+
* Update the remote-tracking branches:
45+
+
46+
------------------------------------------------
47+
$ git fetch origin
48+
------------------------------------------------
49+
+
50+
The above command copies all branches from the remote refs/heads/
51+
namespace and stores them to the local refs/remotes/origin/ namespace,
52+
unless the branch.<name>.fetch option is used to specify a non-default
53+
refspec.
54+
55+
* Using refspecs explicitly:
56+
+
57+
------------------------------------------------
58+
$ git fetch origin +pu:pu maint:tmp
59+
------------------------------------------------
60+
+
61+
This updates (or creates, as necessary) branches `pu` and `tmp` in
62+
the local repository by fetching from the branches (respectively)
63+
`pu` and `maint` from the remote repository.
64+
+
65+
The `pu` branch will be updated even if it is does not fast-forward,
66+
because it is prefixed with a plus sign; `tmp` will not be.
67+
68+
4069
SEE ALSO
4170
--------
4271
linkgit:git-pull[1]

Documentation/git-merge.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,39 @@ You can work through the conflict with a number of tools:
212212
common ancestor, 'git show :2:filename' shows the HEAD
213213
version and 'git show :3:filename' shows the remote version.
214214

215+
216+
EXAMPLES
217+
--------
218+
219+
* Merge branches `fixes` and `enhancements` on top of
220+
the current branch, making an octopus merge:
221+
+
222+
------------------------------------------------
223+
$ git merge fixes enhancements
224+
------------------------------------------------
225+
226+
* Merge branch `obsolete` into the current branch, using `ours`
227+
merge strategy:
228+
+
229+
------------------------------------------------
230+
$ git merge -s ours obsolete
231+
------------------------------------------------
232+
233+
* Merge branch `maint` into the current branch, but do not make
234+
a new commit automatically:
235+
+
236+
------------------------------------------------
237+
$ git merge --no-commit maint
238+
------------------------------------------------
239+
+
240+
This can be used when you want to include further changes to the
241+
merge, or want to write your own merge commit message.
242+
+
243+
You should refrain from abusing this option to sneak substantial
244+
changes into a merge commit. Small fixups like bumping
245+
release/version name would be acceptable.
246+
247+
215248
SEE ALSO
216249
--------
217250
linkgit:git-fmt-merge-msg[1], linkgit:git-pull[1],

Documentation/git-pull.txt

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -131,54 +131,13 @@ $ git pull origin next
131131
------------------------------------------------
132132
+
133133
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:
134+
does not update any remote-tracking branches. Using remote-tracking
135+
branches, the same can be done by invoking fetch and merge:
154136
+
155137
------------------------------------------------
156-
$ git pull --no-commit . maint
138+
$ git fetch origin
139+
$ git merge origin/next
157140
------------------------------------------------
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.
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-
166-
* Command line pull of multiple branches from one repository:
167-
+
168-
------------------------------------------------
169-
$ git checkout master
170-
$ git fetch origin +pu:pu maint:tmp
171-
$ git pull . tmp
172-
------------------------------------------------
173-
+
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.
177-
+
178-
The `pu` branch will be updated even if it is does not fast-forward;
179-
the others will not be.
180-
+
181-
The final command then merges the newly fetched `tmp` into master.
182141

183142

184143
If you tried a pull which resulted in a complex conflicts and

0 commit comments

Comments
 (0)