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 6, 2011, 02:16 UTC
Message-ID
<loom.20110506T034552-210@post.gmane.org>
In-Reply-To
<20110505105914.GA464@sigill.intra.peff.net>
Jeff King <peff <at> peff.net> writes:
Show 14 quoted lines
> 
> On Thu, May 05, 2011 at 10:06:21AM +0000, chris wrote:
> 
> > 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.

If the above command wanted to produce a tag, just provide 'v1.5' as the source ref. It seems to me that first checking out the tag then pushing from HEAD is extra steps in order to push a branch ref without having to be explicit about it. $ git push origin v1.5:foo would have been simpler if intending to push a tag ref.

Given that git-push has specific syntax for pushing a tag, and git-push makes other assumptions that give the perception it is generally used for branches unless told otherwise also makes me expect that "foo" to be a branch.

The following is provided for specifically calling out a tag:
  $ git push origin tag <refspec>

However, that syntax as far as I can tell is pretty worthless anyway, as the following will not work:

  $ git push origin tag HEAD:newtag
  error: src refspec refs/tags/HEAD does not match any.
  $ git push origin tag 183c65e:newtag
  error: src refspec refs/tags/183c65e does not match any.

But both the following are successful, which makes me ask why the 'tag' option exists if the above doesn't work.

  $ git push tag existingtag:newtag1
  $ git push existingtag:newtag2

So I see little purpose in the $ git push tag <refspec> syntax, as the source must already be a tag anyway.

All of that to say, it isn't exactly clear what one should expect.

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
chris
Previous: Jeff KingNext: Junio C Hamano
Message 5 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.