git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Include a git-push example for creating a remote branch
@ 2007-09-06  4:44 Shawn O. Pearce
  2007-09-06  4:54 ` Miles Bader
  2007-09-06 10:50 ` Wincent Colaiuta
  0 siblings, 2 replies; 9+ messages in thread
From: Shawn O. Pearce @ 2007-09-06  4:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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>
---
 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06  4:44 [PATCH] Include a git-push example for creating a remote branch Shawn O. Pearce
@ 2007-09-06  4:54 ` Miles Bader
  2007-09-06  5:01   ` Shawn O. Pearce
  2007-09-06 10:50 ` Wincent Colaiuta
  1 sibling, 1 reply; 9+ messages in thread
From: Miles Bader @ 2007-09-06  4:54 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

"Shawn O. Pearce" <spearce@spearce.org> writes:
> 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.

Hmm, what _does_ it do in that case...?

-Miles

-- 
If you can't beat them, arrange to have them beaten.  [George Carlin]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06  4:54 ` Miles Bader
@ 2007-09-06  5:01   ` Shawn O. Pearce
  2007-09-06  5:57     ` Miles Bader
  0 siblings, 1 reply; 9+ messages in thread
From: Shawn O. Pearce @ 2007-09-06  5:01 UTC (permalink / raw)
  To: Miles Bader; +Cc: Junio C Hamano, git

Miles Bader <miles.bader@necel.com> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> > 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.
> 
> Hmm, what _does_ it do in that case...?

error: dst refspec experimental does not match any existing ref on the remote and does not start with refs/.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06  5:01   ` Shawn O. Pearce
@ 2007-09-06  5:57     ` Miles Bader
  2007-09-06  6:30       ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Miles Bader @ 2007-09-06  5:57 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

On 9/6/07, Shawn O. Pearce <spearce@spearce.org> wrote:
> Miles Bader <miles.bader@necel.com> wrote:
> > > 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.
> >
> > Hmm, what _does_ it do in that case...?
>
> error: dst refspec experimental does not match any existing ref on the remote and does not start with refs/.

Hmm, I'm assuming people don't want to default to just creating a new
remote ref ('cause it might be too easy to muck up a remote archive
that way), but it seems like it would be nice to have a "prettier" way
to create a remote ref than explicitly giving the whole ref path on
the remote side.

Maybe I"m weird, but I tend to think of the refs/... syntax as being
for "only if you're doing something funny" cases.

I'm thinking of something like:

  ... create new local branch "zoink" ...
  git push --create origin zoink

-Miles

-- 
Do not taunt Happy Fun Ball.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06  5:57     ` Miles Bader
@ 2007-09-06  6:30       ` Junio C Hamano
  2007-09-06 15:48         ` Carl Worth
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2007-09-06  6:30 UTC (permalink / raw)
  To: Miles Bader; +Cc: Shawn O. Pearce, Junio C Hamano, git

"Miles Bader" <miles@gnu.org> writes:

> Maybe I"m weird, but I tend to think of the refs/... syntax as being
> for "only if you're doing something funny" cases.

The "refs/" syntax is there as the lowest level that is
universally usable to create and any ref.  It can be used to
push to branches, tags, or even remotes (aka "simulated fetch in
reverse").

It is just nobody felt strong enough reason to sugarcoat the
normalized syntax with something like:

	git push --create remote foo v1.2.0

You can be a hero by updating git-push to take such, and make it
interpret as if the user passed the normalized syntax which is:

	git push remote foo:refs/heads/foo v1.2.0:refs/tags/v1.2.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06  4:44 [PATCH] Include a git-push example for creating a remote branch Shawn O. Pearce
  2007-09-06  4:54 ` Miles Bader
@ 2007-09-06 10:50 ` Wincent Colaiuta
  2007-09-06 14:57   ` Kristian Høgsberg
  1 sibling, 1 reply; 9+ messages in thread
From: Wincent Colaiuta @ 2007-09-06 10:50 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06 10:50 ` Wincent Colaiuta
@ 2007-09-06 14:57   ` Kristian Høgsberg
  0 siblings, 0 replies; 9+ messages in thread
From: Kristian Høgsberg @ 2007-09-06 14:57 UTC (permalink / raw)
  To: Wincent Colaiuta; +Cc: Shawn O. Pearce, Junio C Hamano, git

On Thu, 2007-09-06 at 12:50 +0200, Wincent Colaiuta wrote:
> 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.

Indeed, but a even better approach might be to expand the error message
with a sugestion on how to create a branch.

Kristian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06  6:30       ` Junio C Hamano
@ 2007-09-06 15:48         ` Carl Worth
  2007-09-06 17:42           ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Carl Worth @ 2007-09-06 15:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Miles Bader, Shawn O. Pearce, git

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

On Wed, 05 Sep 2007 23:30:31 -0700, Junio C Hamano wrote:
> It is just nobody felt strong enough reason to sugarcoat the
> normalized syntax with something like:
>
> 	git push --create remote foo v1.2.0

Couldn't we just use an initial + to indicate this as well?

I would imagine an exchange like this:

    $ git push remote foo
    git: No branch 'foo' exists in the remote server, to create it use:

	git push remote +foo

But regardless of the syntax, it would be nice if the error message
were explicit about how to achieve the goal the user wants. It's just
that forcing the user to say "foo:refs/heads/foo" seems a way to force
the user to get plumbing grime on their clean hands.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Include a git-push example for creating a remote branch
  2007-09-06 15:48         ` Carl Worth
@ 2007-09-06 17:42           ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2007-09-06 17:42 UTC (permalink / raw)
  To: Carl Worth; +Cc: Miles Bader, Shawn O. Pearce, git

Carl Worth <cworth@cworth.org> writes:

> On Wed, 05 Sep 2007 23:30:31 -0700, Junio C Hamano wrote:
>> It is just nobody felt strong enough reason to sugarcoat the
>> normalized syntax with something like:
>>
>> 	git push --create remote foo v1.2.0
>
> Couldn't we just use an initial + to indicate this as well?

Unfortunately, no, because + has already been taken to mean
something completely different.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-09-06 17:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-06  4:44 [PATCH] Include a git-push example for creating a remote branch Shawn O. Pearce
2007-09-06  4:54 ` Miles Bader
2007-09-06  5:01   ` Shawn O. Pearce
2007-09-06  5:57     ` Miles Bader
2007-09-06  6:30       ` Junio C Hamano
2007-09-06 15:48         ` Carl Worth
2007-09-06 17:42           ` Junio C Hamano
2007-09-06 10:50 ` Wincent Colaiuta
2007-09-06 14:57   ` Kristian Høgsberg

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).