git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: error with $ git push origin HEAD:newbranch

From
Cchris <jugg@hotmail.com>
Date
May 10, 2011, 15:34 UTC
Message-ID
<loom.20110510T153328-584@post.gmane.org>
In-Reply-To
<20110506170204.GA16576@sigill.intra.peff.net>
Jeff King <peff <at> peff.net> writes:
Show 20 quoted lines
> 
> On Fri, May 06, 2011 at 02:16:03AM +0000, chris wrote:
> 
> > Personally, I would prefer that git-push work on branches by default[1], 
> > providing shortcuts for pushing tag[2] refs and remote branch[3] refs, 
> > while all other ref types must be called out explicitly.  Creating new refs 
> > isn't destructive, so it seems these could be supported without concern.
> > 
> > 1. $ git push origin SHA1:branch1
> >   => $ git push origin SHA1:refs/heads/branch1
> > 
> > 2. $ git push origin tag SHA1:tagname
> >   => $ git push origin SHA1:refs/tags/tagname
> > 
> > 3. $ git push origin SHA1:upstream/branch2
> >   => $ git push origin SHA1:refs/remotes/upstream/branch2
> 
> In (3), how do you differentiate between the branch
> "refs/heads/upstream/branch2" and the remote tracking branch
> "refs/remotes/upstream/branches"?
I was just taking a queue from the documentation:

-- "git push origin master:satellite/master dev:satellite/dev

Use the source ref that matches master (e.g. refs/heads/master) to update the ref that matches satellite/master (most probably refs/remotes/satellite/master) in the origin repository, then do the same for dev and satellite/dev." --

Of course the documentation there is meaninging that refs/remotes/satellite/master already exists and that there is no conflicting refs/heads/satellite/master.

Probably what I need to do is better understand the "guess work" git-push already does before trying to "improve" it. So, based on this thread and the documentation, the following holds true:

  $ git push origin HEAD:newbranch

is valid only if HEAD contains a branch ref pointer. Otherwise, if the LHS of the refspec is not a known ref type, the RHS must always be explicit when pushing a new ref. If the LHS is a known ref type, then the same ref type is used for the RHS of the refspec - also the RHS becomes optional in such a case and the LHS name will be used if the RHS was omitted.

If that is a correct summary (something missing?), then as is, there is little point in anything but explicit specification of the RHS of the refspec when pushing a new ref.

And given that "$ git push remote tag <refspec>" syntax seems to be outdated, I don't see any benefit to my proposed set of shortcuts for pushing new refs.

So, thanks Peff for the informative responses, they helped bring my understanding up a notch.

chris
Previous: Jeff KingNext: Jeff King
Message 9 of 11 in “error with $ git push origin HEAD:newbranch”
  1. chrisMay 5, 2011
  2. Jeff KingMay 5, 2011
  3. chrisMay 5, 2011
  4. Jeff KingMay 5, 2011
  5. chrisMay 6, 2011
  6. Junio C HamanoMay 6, 2011
  7. chrisMay 6, 2011
  8. Jeff KingMay 6, 2011
  9. chrisMay 10, 2011
  10. Jeff KingMay 10, 2011
  11. chrisMay 11, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.