Skip to content

Commit ff6e1b8

Browse files
committed
Merge branch 'jc/checkout-detach-doc'
"git checkout [--detach] <commit>" was listed poorly in the synopsis section of its documentation. * jc/checkout-detach-doc: checkout: update synopsys and documentation on detaching HEAD
2 parents 83f18cd + 26776c9 commit ff6e1b8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Documentation/git-checkout.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git checkout' [-q] [-f] [-m] [<branch>]
12-
'git checkout' [-q] [-f] [-m] [--detach] [<commit>]
12+
'git checkout' [-q] [-f] [-m] --detach [<branch>]
13+
'git checkout' [-q] [-f] [-m] [--detach] <commit>
1314
'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
1415
'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
1516
'git checkout' [-p|--patch] [<tree-ish>] [--] [<paths>...]
@@ -62,7 +63,7 @@ that is to say, the branch is not reset/created unless "git checkout" is
6263
successful.
6364

6465
'git checkout' --detach [<branch>]::
65-
'git checkout' <commit>::
66+
'git checkout' [--detach] <commit>::
6667

6768
Prepare to work on top of <commit>, by detaching HEAD at it
6869
(see "DETACHED HEAD" section), and updating the index and the
@@ -71,10 +72,11 @@ successful.
7172
tree will be the state recorded in the commit plus the local
7273
modifications.
7374
+
74-
Passing `--detach` forces this behavior in the case of a <branch> (without
75-
the option, giving a branch name to the command would check out the branch,
76-
instead of detaching HEAD at it), or the current commit,
77-
if no <branch> is specified.
75+
When the <commit> argument is a branch name, the `--detach` option can
76+
be used to detach HEAD at the tip of the branch (`git checkout
77+
<branch>` would check out that branch without detaching HEAD).
78+
+
79+
Omitting <branch> detaches HEAD at the tip of the current branch.
7880

7981
'git checkout' [-p|--patch] [<tree-ish>] [--] <pathspec>...::
8082

0 commit comments

Comments
 (0)