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