[PATCH] Include a git-push example for creating a remote branch

Subsystems: documentation, the rest

DORMANTno replies

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

[PATCH] Include a git-push example for creating a remote branch

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:33

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 <redacted>
---
 Documentation/git-push.txt |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 0dd9caf..7b8e075 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -117,6 +117,12 @@ git push origin master:satellite/master::
 	the ref that matches `satellite/master` (most likely, it would
 	be `refs/remotes/satellite/master`) in `origin` repository with it.
 
+git push origin master:refs/heads/experimental::
+	Create the branch `experimental` in the `origin` repository
+	by copying the current `master` branch.  This form is usually
+	needed to create a new branch in the remote repository as
+	there is no `experimental` branch to match.
+
 Author
 ------
 Written by Junio C Hamano <junkio@cox.net>, later rewritten in C
-- 
1.5.3.1.840.g0fedbc

Re: [PATCH] Include a git-push example for creating a remote branch

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:33

El 6/9/2007, a las 6:44, Shawn O. Pearce escribió:
+git push origin master:refs/heads/experimental::
+	Create the branch `experimental` in the `origin` repository
+	by copying the current `master` branch.  This form is usually
+	needed to create a new branch in the remote repository as
+	there is no `experimental` branch to match.
+
A welcome addition; I was puzzled the first time I tried this myself  
too.

Cheers,
Wincent

Re: [PATCH] Include a git-push example for creating a remote branch

From: Kristian Høgsberg <hidden>
Date: 2016-06-15 22:43:33

On Thu, 2007-09-06 at 12:50 +0200, Wincent Colaiuta wrote:
El 6/9/2007, a las 6:44, Shawn O. Pearce escribió:
quoted
+git push origin master:refs/heads/experimental::
+	Create the branch `experimental` in the `origin` repository
+	by copying the current `master` branch.  This form is usually
+	needed to create a new branch in the remote repository as
+	there is no `experimental` branch to match.
+
A welcome addition; I was puzzled the first time I tried this myself  
too.
Indeed, but a even better approach might be to expand the error message
with a sugestion on how to create a branch.

Kristian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help