The flag '--' must always be before any file path when <checkout> command is used. The main documentation about the usage of <checkout> command is updated to include the strict usage of the flag '--' so that the user can specify file names over branch names. Signed-off-by: Dannier Castro L <danniercl@xxxxxxxxx>: --- Documentation/git-checkout.txt | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index ca5fc9c..8360a98 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -12,9 +12,9 @@ SYNOPSIS 'git checkout' [-q] [-f] [-m] --detach [<branch>] 'git checkout' [-q] [-f] [-m] [--detach] <commit> 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] -'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... -'git checkout' [<tree-ish>] [--] <pathspec>... -'git checkout' (-p|--patch) [<tree-ish>] [--] [<paths>...] +'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] -- <paths>... +'git checkout' [<tree-ish>] -- <pathspec>... +'git checkout' (-p|--patch) [<tree-ish>] [-- <paths>...] DESCRIPTION ----------- @@ -79,7 +79,7 @@ be used to detach HEAD at the tip of the branch (`git checkout + Omitting <branch> detaches HEAD at the tip of the current branch. -'git checkout' [<tree-ish>] [--] <pathspec>...:: +'git checkout' [<tree-ish>] -- <pathspec>...:: Overwrite paths in the working tree by replacing with the contents in the index or in the <tree-ish> (most often a @@ -95,7 +95,7 @@ specific side of the merge can be checked out of the index by using `--ours` or `--theirs`. With `-m`, changes made to the working tree file can be discarded to re-create the original conflicted merge result. -'git checkout' (-p|--patch) [<tree-ish>] [--] [<pathspec>...]:: +'git checkout' (-p|--patch) [<tree-ish>] [-- <pathspec>...]:: This is similar to the "check out paths to the working tree from either the index or from a tree-ish" mode described above, but lets you use the interactive interface to show @@ -453,7 +453,7 @@ mistake, and gets it back from the index. $ git checkout master <1> $ git checkout master~2 Makefile <2> $ rm -f hello.c -$ git checkout hello.c <3> +$ git checkout -- hello.c <3> ------------ + <1> switch branch @@ -471,14 +471,6 @@ Note the quotes around `*.c`. The file `hello.c` will also be checked out, even though it is no longer in the working tree, because the file globbing is used to match entries in the index (not in the working tree by the shell). -+ -If you have an unfortunate branch that is named `hello.c`, this -step would be confused as an instruction to switch to that branch. -You should instead write: -+ ------------- -$ git checkout -- hello.c ------------- . After working in the wrong branch, switching to the correct branch would be done using: -- 2.7.4