Skip to content

Commit 3f8fc18

Browse files
jrngitster
authored andcommitted
Documentation: flesh out “git pull” description
The current description in the pull man page does not say much more than that “git pull” is fetch + merge. Though that is all a person needs to know in the end, it would be useful to summarize a bit about what those commands do for new readers. Most of this description is taken from the “git merge” docs. Now that we explain how to back out of a failed merge (reset --merge), we can tone down the warning against that a bit. Except, as Thomas noticed, there’s a risk with that because people might read this version of the manpage online and then conclude that it is safe to try a merge with uncommitted changes, only to find that their “git reset” doesn't support --merge yet. Or worse, verify that their git-reset has --merge by a quick test (1b5b465 is in 1.6.2) but then find that it does not help with backing out of a merge (e11d7b5 is only in 1.7.0!). So keep the warning. With clarifications from Ævar, Thomas, and Junio. Noticed-by: Geoff Russell <[email protected]> Cc: Ævar Arnfjörð Bjarmason <[email protected]> Cc: Thomas Rast <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64fdc08 commit 3f8fc18

File tree

1 file changed

+54
-11
lines changed

1 file changed

+54
-11
lines changed

Documentation/git-pull.txt

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,72 @@ git-pull - Fetch from and merge with another repository or a local branch
88

99
SYNOPSIS
1010
--------
11-
'git pull' <options> <repository> <refspec>...
11+
'git pull' [options] [<repository> [<refspec>...]]
1212

1313

1414
DESCRIPTION
1515
-----------
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'.
1916

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.
17+
Incorporates changes from a remote repository into the current
18+
branch. In its default mode, `git pull` is shorthand for
19+
`git fetch` followed by `git merge FETCH_HEAD`.
2320

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'.
21+
More precisely, 'git pull' runs 'git fetch' with the given
22+
parameters and calls 'git merge' to merge the retrieved branch
23+
heads into the current branch.
24+
With `--rebase`, it runs 'git rebase' instead of 'git merge'.
2625

27-
*Warning*: Running 'git pull' (actually, the underlying 'git merge')
26+
<repository> should be the name of a remote repository as
27+
passed to linkgit:git-fetch[1]. <refspec> can name an
28+
arbitrary remote ref (for example, the name of a tag) or even
29+
a collection of refs with corresponding remote tracking branches
30+
(e.g., refs/heads/*:refs/remotes/origin/*), but usually it is
31+
the name of a branch in the remote repository.
32+
33+
Default values for <repository> and <branch> are read from the
34+
"remote" and "merge" configuration for the current branch
35+
as set by linkgit:git-branch[1] `--track`.
36+
37+
Assume the following history exists and the current branch is
38+
"`master`":
39+
40+
------------
41+
A---B---C master on origin
42+
/
43+
D---E---F---G master
44+
------------
45+
46+
Then "`git pull`" will fetch and replay the changes from the remote
47+
`master` branch since it diverged from the local `master` (i.e., `E`)
48+
until its current commit (`C`) on top of `master` and record the
49+
result in a new commit along with the names of the two parent commits
50+
and a log message from the user describing the changes.
51+
52+
------------
53+
A---B---C remotes/origin/master
54+
/ \
55+
D---E---F---G---H master
56+
------------
57+
58+
See linkgit:git-merge[1] for details, including how conflicts
59+
are presented and handled.
60+
61+
In git 1.7.0 or later, to cancel a conflicting merge, use
62+
`git reset --merge`. *Warning*: In older versions of git, running 'git pull'
2863
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.
64+
in a state that may be hard to back out of in the case of a conflict.
65+
66+
If any of the remote changes overlap with local uncommitted changes,
67+
the merge will be automatically cancelled and the work tree untouched.
68+
It is generally best to get any local changes in working order before
69+
pulling or stash them away with linkgit:git-stash[1].
3070

3171
OPTIONS
3272
-------
3373

74+
Options meant for 'git pull' itself and the underlying 'git merge'
75+
must be given before the options meant for 'git fetch'.
76+
3477
-q::
3578
--quiet::
3679
This is passed to both underlying git-fetch to squelch reporting of

0 commit comments

Comments
 (0)