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 11, 2011, 10:10 UTC
Message-ID
<loom.20110511T040830-212@post.gmane.org>
In-Reply-To
<20110510194738.GB14456@sigill.intra.peff.net>
Jeff King <peff <at> peff.net> writes:
Show 25 quoted lines
> 
> On Tue, May 10, 2011 at 03:34:26PM +0000, chris wrote:
> 
> > 
> >   $ 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.
> 
> I think the RHS is always optional, isn't it? That is, if I say:
> 
>   git push origin foo
> 
> then that is always equivalent to
> 
>   git push origin foo:foo
> 
> which will then push to the matching "foo" on the remote; if it does not
> exist, then it will infer the type of "foo" on the remote from the type
> of "foo" locally. But I could be mis-remembering, as it's been a while
> since I've dug into the refspec code.
Yes, but I was distinguishing when the LHS is not a known ref type
  $ git push origin HEAD^

isn't valid. So, my meaning was RHS only becomes optional if the LHS resolves to a local ref. Which may be obvious; I was just trying to cover the use cases.

I think the generalization is that git-push tries to build the refspec using hints from the local ref part. If it can not do so, it fails rather than defaulting to any particular behavior.

chris
Previous: Jeff King
Message 11 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.