Skip to content

Commit 19e5656

Browse files
pcloudsgitster
authored andcommitted
checkout.txt: document a common case that ignores ambiguation rules
Normally we err on the safe side: if something can be seen as both an SHA1 and a pathspec, we stop and scream. In checkout, there is one exception added in 859fdab (git-checkout: improve error messages, detect ambiguities. - 2008-07-23), to allow the common case "git checkout branch". Let's document this exception. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7f82b24 commit 19e5656

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Documentation/git-checkout.txt

+12
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,18 @@ $ git reflog -2 HEAD # or
419419
$ git log -g -2 HEAD
420420
------------
421421

422+
ARGUMENT DISAMBIGUATION
423+
-----------------------
424+
425+
When there is only one argument given and it is not `--` (e.g. "git
426+
checkout abc"), and when the argument is both a valid `<tree-ish>`
427+
(e.g. a branch "abc" exists) and a valid `<pathspec>` (e.g. a file
428+
or a directory whose name is "abc" exists), Git would usually ask
429+
you to disambiguate. Because checking out a branch is so common an
430+
operation, however, "git checkout abc" takes "abc" as a `<tree-ish>`
431+
in such a situation. Use `git checkout -- <pathspec>` if you want
432+
to checkout these paths out of the index.
433+
422434
EXAMPLES
423435
--------
424436

0 commit comments

Comments
 (0)