From: Jeff King Date: Thu, 05 May 2011 10:59:14 GMT Subject: Re: error with $ git push origin HEAD:newbranch Message-ID: <20110505105914.GA464@sigill.intra.peff.net> In-Reply-To: On Thu, May 05, 2011 at 10:06:21AM +0000, chris wrote: > 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