Junio C Hamano <gitster@xxxxxxxxx> wrote: > perryh@xxxxxxxxxxxxxx (Perry Hutchison) writes: > > > $ git rev-parse r5.0.1 > > r5.0.1 > > fatal: ambiguous argument 'r5.0.1': unknown revision or path not in the working tree. > > Use '--' to separate paths from revisions > > This is not because of ambiguity among refs. The message is telling > you: > > r5.0.1 is not interpretable as a revision, and it is not likely > to be interpretable as a path. If you meant to use it as a > revision, put '--' after it, if you meant to use it as a path, > put '--' before it. > ... > Now, admittably, if you say "git rev-parse r5.0.1 --" in this > situation, it is not likely that the corrected command line will > succeed. Yes, I tried that also. It didn't work. > ... we do not say "append 'refs/remotes/<anything>/' for various > values of <anything> and see if such a ref exists" when resolving > an abbreviated refname 'master'. checkout appears to. If I enter "git checkout foo" and the local branch refs/heads/foo exists checkout will: 1. recognize that foo refers to a local branch 2. check out that local branch (refs/heads/foo). OTOH, if I enter "git checkout foo" and there is no foo in refs/heads or refs/tags and refs/remotes/origin/foo _does_ exist checkout will: 1. recognize that foo refers to a remote branch 2. set up a local branch (refs/heads/foo) that tracks the remote branch (refs/remotes/origin/foo) 3. check out the (now) local branch (refs/heads/foo). However I don't think the command I want is spelled "checkout" because, in either case, I want just step 1 -- with the result being returned as the HEAD commit id of the selected branch. I don't want the whole checkout experience, just the identification of the commit that is the HEAD of the specified branch, which may be either local (in refs/heads) or remote (in refs/heads/origin). It is certainly possible that the command I am looking for is not spelled "rev-parse" either -- and it does not matter whether it is considered plumbing or porcelain. It just needs to produce the correct result, for either the local or the remote case. (In the situation at hand I happen to know that the name will always refer to a branch, not a tag, so a solution that looks only in refs/heads and refs/remotes -- and not in refs/tags -- would be fine. A solution that, like checkout, also looks in refs/tags would also be OK.) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html