Re: error with $ git push origin HEAD:newbranch
- From
- chris <jugg@hotmail.com>
- Date
- May 10, 2011, 15:34 UTC
- Message-ID
- <loom.20110510T153328-584@post.gmane.org>
- In-Reply-To
- <20110506170204.GA16576@sigill.intra.peff.net>
Jeff King <peff <at> peff.net> writes:
Show 20 quoted lines
> > On Fri, May 06, 2011 at 02:16:03AM +0000, chris wrote: > > > 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 > > In (3), how do you differentiate between the branch > "refs/heads/upstream/branch2" and the remote tracking branch > "refs/remotes/upstream/branches"?
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.
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.
If that is a correct summary (something missing?), then as is, there is little point in anything but explicit specification of the RHS of the refspec when pushing a new ref.
And given that "$ git push remote tag <refspec>" syntax seems to be outdated, I don't see any benefit to my proposed set of shortcuts for pushing new refs.
So, thanks Peff for the informative responses, they helped bring my understanding up a notch.
chris