From e1cdf63316348332e4e267aeaab5b510beae0227 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Mon, 17 Dec 2012 00:45:01 -0600 Subject: [PATCH] Documentation/git-checkout.txt: clarify usage The forms of checkout that do not take a path are lumped together in the DESCRIPTION section, but the description for this group is dominated by explanation of the -b|-B form. Split these apart for more clarity. Signed-off-by: Chris Rorvick Signed-off-by: Junio C Hamano --- Documentation/git-checkout.txt | 43 ++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 7958a4700..ad33eb49a 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -21,18 +21,26 @@ or the specified tree. If no paths are given, 'git checkout' will also update `HEAD` to set the specified branch as the current branch. -'git checkout' []:: +'git checkout' :: + To prepare for working on , switch to it by updating + the index and the files in the working tree, and by pointing + HEAD at the branch. Local modifications to the files in the + working tree are kept, so that they can be committed to the + . ++ +You could omit , in which case the command degenerates to +"check out the current branch", which is a glorified no-op with a +rather expensive side-effects to show only the tracking information, +if exists, for the current branch. + 'git checkout' -b|-B []:: -'git checkout' [--detach] []:: - This form switches branches by updating the index, working - tree, and HEAD to reflect the specified branch or commit. -+ -If `-b` is given, a new branch is created as if linkgit:git-branch[1] -were called and then checked out; in this case you can -use the `--track` or `--no-track` options, which will be passed to -'git branch'. As a convenience, `--track` without `-b` implies branch -creation; see the description of `--track` below. + Specifying `-b` causes a new branch to be created as if + linkgit:git-branch[1] were called and then checked out. In + this case you can use the `--track` or `--no-track` options, + which will be passed to 'git branch'. As a convenience, + `--track` without `-b` implies branch creation; see the + description of `--track` below. + If `-B` is given, is created if it doesn't exist; otherwise, it is reset. This is the transactional equivalent of @@ -45,6 +53,21 @@ $ git checkout that is to say, the branch is not reset/created unless "git checkout" is successful. +'git checkout' --detach []:: +'git checkout' :: + + Prepare to work on top of , by detaching HEAD at it + (see "DETACHED HEAD" section), and updating the index and the + files in the working tree. Local modifications to the files + in the working tree are kept, so that the resulting working + tree will be the state recorded in the commit plus the local + modifications. ++ +Passing `--detach` forces this behavior in the case of a (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 is specified. + 'git checkout' [-p|--patch] [] [--] ...:: When or `--patch` are given, 'git checkout' does *not* -- 2.11.0