Skip to content

Commit

Permalink
checkout: update synopsys and documentation on detaching HEAD
Browse files Browse the repository at this point in the history
In the synopsis, the second form to detach HEAD at the named commit
labelled the argument as '<commit>'.  While this is technically more
correct, because the feature to detach is not limited to the tip of
a named branch, it was found confusing and did not express the fact
that you have to give `--detach` if you are naming the commit you
want to detach HEAD at with a branch name.

Separate this case into two syntactical forms, mimicking the way how
the DESCRIPTION section shows this usage.  Also update the text that
explains the syntax to name the commit to detach HEAD at to clarify.

Suggested-by: Benjamin Bergman <ben@benbergman.ca>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
gitster committed Sep 11, 2013
1 parent 2ea3df6 commit 26776c9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Documentation/git-checkout.txt
Expand Up @@ -9,7 +9,8 @@ SYNOPSIS
--------
[verse]
'git checkout' [-q] [-f] [-m] [<branch>]
'git checkout' [-q] [-f] [-m] [--detach] [<commit>]
'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' [-p|--patch] [<tree-ish>] [--] [<paths>...]
Expand Down Expand Up @@ -62,7 +63,7 @@ that is to say, the branch is not reset/created unless "git checkout" is
successful.

'git checkout' --detach [<branch>]::
'git checkout' <commit>::
'git checkout' [--detach] <commit>::

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

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

Expand Down

0 comments on commit 26776c9

Please sign in to comment.