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 5, 2011, 10:59 UTC
Message-ID
<20110505105914.GA464@sigill.intra.peff.net>
In-Reply-To
<loom.20110505T114511-660@post.gmane.org>
On Thu, May 05, 2011 at 10:06:21AM +0000, chris wrote:
Show 8 quoted lines
> Yes, indeed.  I suppose it must be the situation that I've never done that
> before then.  While I certainly I have pushed a detached head before, it must 
> have always been to an existing branch.
> 
> Thanks for clarifying this.
> 
> It is slightly surprising that git-push doesn't default to assuming one means 
> refs/heads/newbranch in this case.  I don't see a reason not to?
Consider something like:
  $ git checkout v1.5
  $ git push origin HEAD:foo

Would you want "foo" to be a branch or a tag? I can see arguments for either.

Rather than trying to guess, it's fairly easy to disambiguate. For a branch, either:

  $ git push origin HEAD:refs/heads/foo
or
  $ git branch foo
  $ git push origin HEAD
would work, depending on whether or not you want a local branch.
-Peff
Previous: chrisNext: chris
Message 4 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.