Skip to content

Commit 73d24df

Browse files
committed
doc: git-checkout: clarify git checkout <branch>
- "To prepare for working on _<branch>_..." is confusing to some users: it makes it sound like these are steps that the user has to do, not steps that Git itself will do. Reword it. - Use "changes" instead of "modifications" (which Git normally does) - Mention that `git checkout` will fail if there's a merge conflict - The current explanation of `You could omit <branch>`... is confusing to users (what are the "expensive side effects"? what's a better way of getting the same info?). Be more direct and mention that `git status` is likely a better option. Signed-off-by: Julia Evans <[email protected]>
1 parent 92eec55 commit 73d24df

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Documentation/git-checkout.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ See ARGUMENT DISAMBIGUATION below for how Git decides which one to do.
3030
Here's a description of all of the modes:
3131
3232
`git checkout [<branch>]`::
33-
To prepare for working on _<branch>_, switch to it by updating
34-
the index and the files in the working tree, and by pointing
35-
`HEAD` at the branch. Local modifications to the files in the
36-
working tree are kept, so that they can be committed to the
37-
_<branch>_.
33+
Switch to _<branch>_. This will update the files in the working tree,
34+
point `HEAD` at the branch, and update the index. Local changes to
35+
the files in the working tree are kept, so that they can be committed
36+
to the _<branch>_. If the local changes conflict with the changes on
37+
_<branch>_, no changes will be made and the checkout operation will
38+
fail.
3839
+
3940
If _<branch>_ is not found but there does exist a tracking branch in
4041
exactly one remote (call it _<remote>_) with a matching name and
@@ -44,10 +45,9 @@ exactly one remote (call it _<remote>_) with a matching name and
4445
$ git checkout -b <branch> --track <remote>/<branch>
4546
------------
4647
+
47-
You could omit _<branch>_, in which case the command degenerates to
48-
"check out the current branch", which is a glorified no-op with
49-
rather expensive side-effects to show only the tracking information,
50-
if it exists, for the current branch.
48+
Running `git checkout` without specifying a branch will output the
49+
tracking information, if it exists, for the current branch, but it's
50+
slower than getting the same information from `git status`.
5151
5252
`git checkout (-b|-B) <new-branch> [<start-point>]`::
5353

0 commit comments

Comments
 (0)