Skip to content

Commit 7b26171

Browse files
committed
Merge branch 'am/maint-push-doc' into maint
* am/maint-push-doc: Documentation: rework src/dst description in git push Documentation: more git push examples Documentation: simplify refspec format description
2 parents f20408d + 8039184 commit 7b26171

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

Documentation/git-push.txt

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,27 @@ OPTIONS
3333
of a remote (see the section <<REMOTES,REMOTES>> below).
3434

3535
<refspec>...::
36-
The canonical format of a <refspec> parameter is
37-
`+?<src>:<dst>`; that is, an optional plus `{plus}`, followed
38-
by the source ref, followed by a colon `:`, followed by
39-
the destination ref.
36+
The format of a <refspec> parameter is an optional plus
37+
`{plus}`, followed by the source ref <src>, followed
38+
by a colon `:`, followed by the destination ref <dst>.
39+
It is used to specify with what <src> object the <dst> ref
40+
in the remote repository is to be updated.
4041
+
41-
The <src> side represents the source branch (or arbitrary
42-
"SHA1 expression", such as `master~4` (four parents before the
43-
tip of `master` branch); see linkgit:git-rev-parse[1]) that you
44-
want to push. The <dst> side represents the destination location.
42+
The <src> is often the name of the branch you would want to push, but
43+
it can be any arbitrary "SHA-1 expression", such as `master~4` or
44+
`HEAD` (see linkgit:git-rev-parse[1]).
4545
+
46-
The local ref that matches <src> is used
47-
to fast forward the remote ref that matches <dst>. If
48-
the optional leading plus `+` is used, the remote ref is updated
49-
even if it does not result in a fast forward update.
46+
The <dst> tells which ref on the remote side is updated with this
47+
push. Arbitrary expressions cannot be used here, an actual ref must
48+
be named. If `:`<dst> is omitted, the same ref as <src> will be
49+
updated.
5050
+
51-
`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
51+
The object referenced by <src> is used to fast forward the ref <dst>
52+
on the remote side. If the optional leading plus `{plus}` is used, the
53+
remote ref is updated even if it does not result in a fast forward
54+
update.
5255
+
53-
A lonely <src> parameter (without a colon and a destination) pushes
54-
the <src> to the same name in the destination repository.
56+
`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
5557
+
5658
Pushing an empty <src> allows you to delete the <dst> ref from
5759
the remote repository.
@@ -190,23 +192,33 @@ git push origin master::
190192
with it. If `master` did not exist remotely, it would be
191193
created.
192194

193-
git push origin :experimental::
194-
Find a ref that matches `experimental` in the `origin` repository
195-
(e.g. `refs/heads/experimental`), and delete it.
195+
git push origin HEAD::
196+
A handy way to push the current branch to the same name on the
197+
remote.
196198

197199
git push origin master:satellite/master dev:satellite/dev::
198200
Use the source ref that matches `master` (e.g. `refs/heads/master`)
199201
to update the ref that matches `satellite/master` (most probably
200202
`refs/remotes/satellite/master`) in the `origin` repository, then
201203
do the same for `dev` and `satellite/dev`.
202204

205+
git push origin HEAD:master::
206+
Push the current branch to the remote ref matching `master` in the
207+
`origin` repository. This form is convenient to push the current
208+
branch without thinking about its local name.
209+
203210
git push origin master:refs/heads/experimental::
204211
Create the branch `experimental` in the `origin` repository
205212
by copying the current `master` branch. This form is only
206213
needed to create a new branch or tag in the remote repository when
207214
the local name and the remote name are different; otherwise,
208215
the ref name on its own will work.
209216

217+
git push origin :experimental::
218+
Find a ref that matches `experimental` in the `origin` repository
219+
(e.g. `refs/heads/experimental`), and delete it.
220+
221+
210222
Author
211223
------
212224
Written by Junio C Hamano <[email protected]>, later rewritten in C

Documentation/pull-fetch-param.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
of a remote (see the section <<REMOTES,REMOTES>> below).
66

77
<refspec>::
8-
The canonical format of a <refspec> parameter is
9-
`+?<src>:<dst>`; that is, an optional plus `{plus}`, followed
10-
by the source ref, followed by a colon `:`, followed by
11-
the destination ref.
8+
The format of a <refspec> parameter is an optional plus
9+
`{plus}`, followed by the source ref <src>, followed
10+
by a colon `:`, followed by the destination ref <dst>.
1211
+
1312
The remote ref that matches <src>
1413
is fetched, and if <dst> is not empty string, the local
1514
ref that matches it is fast forwarded using <src>.
16-
Again, if the optional plus `+` is used, the local ref
15+
If the optional plus `+` is used, the local ref
1716
is updated even if it does not result in a fast forward
1817
update.
1918
+

0 commit comments

Comments
 (0)