Skip to content

Commit 4e56015

Browse files
spearcegitster
authored andcommitted
Include a git-push example for creating a remote branch
Many users get confused when `git push origin master:foo` works when foo already exists on the remote repository but are confused when foo doesn't exist as a branch and this form does not create the branch foo. This new example highlights the trick of including refs/heads/ in front of the desired branch name to create a branch. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 432e93a commit 4e56015

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Documentation/git-push.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ git push origin master:satellite/master::
117117
the ref that matches `satellite/master` (most likely, it would
118118
be `refs/remotes/satellite/master`) in `origin` repository with it.
119119

120+
git push origin master:refs/heads/experimental::
121+
Create the branch `experimental` in the `origin` repository
122+
by copying the current `master` branch. This form is usually
123+
needed to create a new branch in the remote repository as
124+
there is no `experimental` branch to match.
125+
120126
Author
121127
------
122128
Written by Junio C Hamano <junkio@cox.net>, later rewritten in C

0 commit comments

Comments
 (0)