@matheusbsbs / matheus-bagliano / commits / bccf5956c3
Fork 0

Added a few examples to git-pull man page.

Clarified and added notes for pull/push refspecs. Converted to back-ticks for literal text examples. [jc: Also fixed git-pull description that still talked about its calling git-resolve or git-octopus (we do not anymore; instead we just call git-merge). BTW, I am reasonably impressed by how well "git-am -3" applied this patch, which had some conflicts because I've updated the documentation somewhat.] Signed-off-by: Jon Loeliger <jdl@freescale.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jon Loeliger committed Nov 4, 2005 at 20:36 UTC bccf5956c323a043e9a5d540b3c842ae6e5e5220
2 files changed +103 -32
Documentation/git-pull.txt
+54 -9
@@ -13,13 +13,10 @@ SYNOPSIS
13
14 DESCRIPTION
15 -----------
16 -Runs 'git-fetch' with the given parameters.
16 +Runs `git-fetch` with the given parameters, and calls `git-merge`
17 +to merge the retrieved head(s) into the current branch.
18
18 -When only one ref is downloaded, runs 'git resolve' to merge it
19 -into the local HEAD. Otherwise uses 'git octopus' to merge them
20 -into the local HEAD.
21 -
22 -Note that you can use '.' (current directory) as the
19 +Note that you can use `.` (current directory) as the
20 <repository> to pull from the local repository -- this is useful
21 when merging local branches into the current branch.
22
@@ -29,8 +26,8 @@ include::pull-fetch-param.txt[]
26
27 -a, \--append::
28 Append ref names and object names of fetched refs to the
32 - existing contents of $GIT_DIR/FETCH_HEAD. Without this
33 - option old data in $GIT_DIR/FETCH_HEAD will be overwritten.
29 + existing contents of `$GIT_DIR/FETCH_HEAD`. Without this
30 + option old data in `$GIT_DIR/FETCH_HEAD` will be overwritten.
31
32 include::merge-pull-opts.txt[]
33
@@ -97,6 +94,52 @@ You should refrain from abusing this option to sneak substantial
94 changes into a merge commit. Small fixups like bumping
95 release/version name would be acceptable.
96
97 +Command line pull of multiple branches from one repository::
98 ++
99 +------------------------------------------------
100 +$ cat .git/remotes/origin
101 +URL: git://git.kernel.org/pub/scm/git/git.git
102 +Pull: master:origin
103 +
104 +$ git checkout master
105 +$ git fetch origin master:origin +pu:pu maint:maint
106 +$ git pull . origin
107 +------------------------------------------------
108 ++
109 +Here, a typical `$GIT_DIR/remotes/origin` file from a
110 +`git-clone` operation is used in combination with
111 +command line options to `git-fetch` to first update
112 +multiple branches of the local repository and then
113 +to merge the remote `origin` branch into the local
114 +`master` branch. The local `pu` branch is updated
115 +even if it does not result in a fast forward update.
116 +Here, the pull can obtain its objects from the local
117 +repository using `.`, as the previous `git-fetch` is
118 +known to have already obtained and made available
119 +all the necessary objects.
120 +
121 +
122 +Pull of multiple branches from one repository using `$GIT_DIR/remotes` file::
123 ++
124 +------------------------------------------------
125 +$ cat .git/remotes/origin
126 +URL: git://git.kernel.org/pub/scm/git/git.git
127 +Pull: master:origin
128 +Pull: +pu:pu
129 +Pull: maint:maint
130 +
131 +$ git checkout master
132 +$ git pull origin
133 +------------------------------------------------
134 ++
135 +Here, a typical `$GIT_DIR/remotes/origin` file from a
136 +`git-clone` operation has been hand-modified to include
137 +the branch-mapping of additional remote and local
138 +heads directly. A single `git-pull` operation while
139 +in the `master` branch will fetch multiple heads and
140 +merge the remote `origin` head into the current,
141 +local `master` branch.
142 +
143
144 Author
145 ------
@@ -105,7 +148,9 @@ and Junio C Hamano <junkio@cox.net>
148
149 Documentation
150 --------------
108 -Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
151 +Documentation by Jon Loeliger,
152 +David Greaves,
153 +Junio C Hamano and the git-list <git@vger.kernel.org>.
154
155 GIT
156 ---
Documentation/pull-fetch-param.txt
+49 -23
@@ -1,7 +1,8 @@
1 <repository>::
2 - The "remote" repository to pull from. One of the
3 - following notations can be used to name the repository
4 - to pull from:
2 + The "remote" repository that is the source of a fetch
3 + or pull operation, or the destination of a push operation.
4 + One of the following notations can be used
5 + to name the remote repository:
6 +
7 ===============================================================
8 - Rsync URL: rsync://remote.machine/path/to/repo.git/
@@ -12,7 +13,7 @@
13 ===============================================================
14 +
15 In addition to the above, as a short-hand, the name of a
15 -file in $GIT_DIR/remotes directory can be given; the
16 +file in `$GIT_DIR/remotes` directory can be given; the
17 named file should be in the following format:
18 +
19 URL: one of the above URL format
@@ -21,57 +22,82 @@ named file should be in the following format:
22 +
23 When such a short-hand is specified in place of
24 <repository> without <refspec> parameters on the command
24 -line, <refspec>... specified on Push lines or Pull lines
25 -are used for "git push" and "git fetch/pull",
26 -respectively.
25 +line, <refspec>... specified on `Push:` lines or `Pull:`
26 +lines are used for `git-push` and `git-fetch`/`git-pull`,
27 +respectively. Multiple `Push:` and and `Pull:` lines may
28 +be specified for additional branch mappings.
29 +
28 -The name of a file in $GIT_DIR/branches directory can be
30 +The name of a file in `$GIT_DIR/branches` directory can be
31 specified as an older notation short-hand; the named
32 file should contain a single line, a URL in one of the
31 -above formats, optionally followed by a hash '#' and the
33 +above formats, optionally followed by a hash `#` and the
34 name of remote head (URL fragment notation).
33 -$GIT_DIR/branches/<remote> file that stores a <url>
35 +`$GIT_DIR/branches/<remote>` file that stores a <url>
36 without the fragment is equivalent to have this in the
35 -corresponding file in the $GIT_DIR/remotes/ directory
37 +corresponding file in the `$GIT_DIR/remotes/` directory.
38 +
39 URL: <url>
40 Pull: refs/heads/master:<remote>
41 +
40 -while having <url>#<head> is equivalent to
42 +while having `<url>#<head>` is equivalent to
43 +
44 URL: <url>
45 Pull: refs/heads/<head>:<remote>
46
47 <refspec>::
48 The canonical format of a <refspec> parameter is
47 - '+?<src>:<dst>'; that is, an optional plus '+', followed
48 - by the source ref, followed by a colon ':', followed by
49 + `+?<src>:<dst>`; that is, an optional plus `+`, followed
50 + by the source ref, followed by a colon `:`, followed by
51 the destination ref.
52 +
51 -When used in "git push", the <src> side can be an
53 +When used in `git-push`, the <src> side can be an
54 arbitrary "SHA1 expression" that can be used as an
53 -argument to "git-cat-file -t". E.g. "master~4" (push
55 +argument to `git-cat-file -t`. E.g. `master~4` (push
56 four parents before the current master head).
57 +
56 -For "git push", the local ref that matches <src> is used
58 +For `git-push`, the local ref that matches <src> is used
59 to fast forward the remote ref that matches <dst>. If
58 -the optional plus '+' is used, the remote ref is updated
60 +the optional plus `+` is used, the remote ref is updated
61 even if it does not result in a fast forward update.
62 +
61 -For "git fetch/pull", the remote ref that matches <src>
63 +For `git-fetch` and `git-pull`, the remote ref that matches <src>
64 is fetched, and if <dst> is not empty string, the local
65 ref that matches it is fast forwarded using <src>.
64 -Again, if the optional plus '+' is used, the local ref
66 +Again, if the optional plus `+` is used, the local ref
67 is updated even if it does not result in a fast forward
68 update.
69 +
70 +[NOTE]
71 +If the remote branch from which you want to pull is
72 +modified in non-linear ways such as being rewound and
73 +rebased frequently, then a pull will attempt a merge with
74 +an older version of itself, likely conflict, and fail.
75 +It is under these conditions that you would want to use
76 +the `+` sign to indicate non-fast-forward updates will
77 +be needed. There is currently no easy way to determine
78 +or declare that a branch will be made available in a
79 +repository with this behavior; the pulling user simply
80 +must know this is the expected usage pattern for a branch.
81 ++
82 +[NOTE]
83 +You never do your own development on branches that appear
84 +on the right hand side of a <refspec> colon on `Pull:` lines;
85 +they are to be updated by `git-fetch`. The corollary is that
86 +a local branch should be introduced and named on a <refspec>
87 +right-hand-side if you intend to do development derived from
88 +that branch.
89 +This leads to the common `Pull: master:origin` mapping of a
90 +remote `master` branch to a local `origin` branch, which
91 +is then merged to a local development branch, again typically
92 +named `master`.
93 ++
94 Some short-cut notations are also supported.
95 +
70 -* For backward compatibility, "tag" is almost ignored;
96 +* For backward compatibility, `tag` is almost ignored;
97 it just makes the following parameter <tag> to mean a
72 - refspec "refs/tags/<tag>:refs/tags/<tag>".
98 + refspec `refs/tags/<tag>:refs/tags/<tag>`.
99 * A parameter <ref> without a colon is equivalent to
74 - <ref>: when pulling/fetching, and <ref>:<ref> when
100 + <ref>: when pulling/fetching, and <ref>`:`<ref> when
101 pushing. That is, do not store it locally if
102 fetching, and update the same name if pushing.
103