Re: [RFC] Reverting individual files to HEAD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El 10/9/2007, a las 10:03, Junio C Hamano escribió:

I don't see any mention of "git checkout HEAD" in the user manual.

"git checkout <arbitrary-commit> paths" would universally cover
that.  Do you really want to see the documentation to spoon feed
any and all possible <arbitrary-commit> as example there?

Give us a break.

One thing that I do think would be usefully added to the man page is a description of what happens when there is ambiguity between your "tree-ish", "branch" and "paths" parameters. eg. when "git checkout foo" could conceivably refer to branch foo, path foo, or (tree-ish) tag foo etc.

My experimentation shows that:

- if "foo" is both a path and a branch name then git interprets "git checkout foo" as referring to the branch.

- if "foo" is both a path and a tag name then git interpets "git checkout foo" as referring to the tag

- if "foo" is both a tag name and a branch name then git interprets "git checkout foo" as referring to the branch

So the precedence seems to be: branch -> tag -> path

I think it would be useful to add some clarification to the man page about this stating how things are disambiguated and how you can overcome ambiguity in these cases by specifically referring to the entity that you're interested in. Perhaps this stuff is already in the docs somewhere and I just haven't seen it.

Another thing that might be useful is if git could detect this kind of ambiguity and issue a warning of the sort:

  error: ambiguous reference to "foo"
  If you meant to checkout the branch "foo", do ...
  If you meant to checkout the tag "foo", do ...
If you meant to checkout the path "foo", do git checkout HEAD foo ... etc

Admittedly, I try to avoid these things by not giving my files names like "master" or creating tags like "v1.0.0" and then adding files with the same name, but it would be nice for beginning users if you didn't have to think about this class of potential ambiguities.

Cheers,
Wincent


-
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux