Documentation/push: clarify matching refspec behavior
[git/dscho.git] / Documentation / git-push.txt
blob650ee91483b097d081d7b85d1053670aa3dee2df
1 git-push(1)
2 ===========
4 NAME
5 ----
6 git-push - Update remote refs along with associated objects
9 SYNOPSIS
10 --------
11 [verse]
12 'git-push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
13            [--repo=all] [-f | --force] [-v | --verbose] [<repository> <refspec>...]
15 DESCRIPTION
16 -----------
18 Updates remote refs using local refs, while sending objects
19 necessary to complete the given refs.
21 You can make interesting things happen to a repository
22 every time you push into it, by setting up 'hooks' there.  See
23 documentation for linkgit:git-receive-pack[1].
26 OPTIONS
27 -------
28 <repository>::
29         The "remote" repository that is destination of a push
30         operation.  See the section <<URLS,GIT URLS>> below.
32 <refspec>::
33         The canonical format of a <refspec> parameter is
34         `+?<src>:<dst>`; that is, an optional plus `+`, followed
35         by the source ref, followed by a colon `:`, followed by
36         the destination ref.
38 The <src> side can be an
39 arbitrary "SHA1 expression" that can be used as an
40 argument to `git-cat-file -t`.  E.g. `master~4` (push
41 four parents before the current master head).
43 The local ref that matches <src> is used
44 to fast forward the remote ref that matches <dst>.  If
45 the optional plus `+` is used, the remote ref is updated
46 even if it does not result in a fast forward update.
48 Note: If no explicit refspec is found, (that is neither
49 on the command line nor in any Push line of the
50 corresponding remotes file---see below), then "matching" heads are
51 pushed: for every head that exists on the local side, the remote side is
52 updated if a head of the same name already exists on the remote side.
54 `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
56 A parameter <ref> without a colon pushes the <ref> from the source
57 repository to the destination repository under the same name.
59 Pushing an empty <src> allows you to delete the <dst> ref from
60 the remote repository.
62 \--all::
63         Instead of naming each ref to push, specifies that all
64         refs under `$GIT_DIR/refs/heads/` be pushed.
66 \--mirror::
67         Instead of naming each ref to push, specifies that all
68         refs under `$GIT_DIR/refs/heads/` and `$GIT_DIR/refs/tags/`
69         be mirrored to the remote repository.  Newly created local
70         refs will be pushed to the remote end, locally updated refs
71         will be force updated on the remote end, and deleted refs
72         will be removed from the remote end.
74 \--dry-run::
75         Do everything except actually send the updates.
77 \--tags::
78         All refs under `$GIT_DIR/refs/tags` are pushed, in
79         addition to refspecs explicitly listed on the command
80         line.
82 \--receive-pack=<git-receive-pack>::
83         Path to the 'git-receive-pack' program on the remote
84         end.  Sometimes useful when pushing to a remote
85         repository over ssh, and you do not have the program in
86         a directory on the default $PATH.
88 \--exec=<git-receive-pack>::
89         Same as \--receive-pack=<git-receive-pack>.
91 -f, \--force::
92         Usually, the command refuses to update a remote ref that is
93         not an ancestor of the local ref used to overwrite it.
94         This flag disables the check.  This can cause the
95         remote repository to lose commits; use it with care.
97 \--repo=<repo>::
98         When no repository is specified the command defaults to
99         "origin"; this overrides it.
101 \--thin, \--no-thin::
102         These options are passed to `git-send-pack`.  Thin
103         transfer spends extra cycles to minimize the number of
104         objects to be sent and meant to be used on slower connection.
106 -v, \--verbose::
107         Run verbosely.
109 include::urls-remotes.txt[]
112 Examples
113 --------
115 git push origin master::
116         Find a ref that matches `master` in the source repository
117         (most likely, it would find `refs/heads/master`), and update
118         the same ref (e.g. `refs/heads/master`) in `origin` repository
119         with it.
121 git push origin :experimental::
122         Find a ref that matches `experimental` in the `origin` repository
123         (e.g. `refs/heads/experimental`), and delete it.
125 git push origin master:satellite/master::
126         Find a ref that matches `master` in the source repository
127         (most likely, it would find `refs/heads/master`), and update
128         the ref that matches `satellite/master` (most likely, it would
129         be `refs/remotes/satellite/master`) in `origin` repository with it.
131 git push origin master:refs/heads/experimental::
132         Create the branch `experimental` in the `origin` repository
133         by copying the current `master` branch.  This form is usually
134         needed to create a new branch in the remote repository as
135         there is no `experimental` branch to match.
137 Author
138 ------
139 Written by Junio C Hamano <junkio@cox.net>, later rewritten in C
140 by Linus Torvalds <torvalds@osdl.org>
142 Documentation
143 --------------
144 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
148 Part of the linkgit:git[7] suite