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

Re: error with $ git push origin HEAD:newbranch

From
Jeff King <peff@peff.net>
Date
May 10, 2011, 19:47 UTC
Message-ID
<20110510194738.GB14456@sigill.intra.peff.net>
In-Reply-To
<loom.20110510T153328-584@post.gmane.org>
On Tue, May 10, 2011 at 03:34:26PM +0000, chris wrote:
Show 13 quoted lines
> 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.

Right. All of our discussion has been on the case where the RHS doesn't match anything on the remote.

Show 11 quoted lines
> 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.
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.

Other than that, I think your description above is accurate.
-Peff
Previous: chrisNext: chris
Message 10 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.