Skip to content

Commit 23a7389

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 48e7f23 commit 23a7389

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Documentation/git-checkout.adoc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ DESCRIPTION
2828
See ARGUMENT DISAMBIGUATION below for how Git decides which one to do.
2929
3030
`git checkout [<branch>]`::
31-
To prepare for working on _<branch>_, switch to it by updating
32-
the index and the files in the working tree, and by pointing
33-
`HEAD` at the branch. Local modifications to the files in the
34-
working tree are kept, so that they can be committed to the
35-
_<branch>_.
31+
Switch to _<branch>_. This sets the current branch to <branch> and
32+
updates the files in your working directory. Local changes to
33+
the files in the working tree are kept, so that they can be committed
34+
to the _<branch>_. If the local changes can't be cleanly merged into
35+
the _<branch>_, no changes will be made and the checkout operation will fail.
3636
+
3737
If _<branch>_ is not found but there does exist a tracking branch in
3838
exactly one remote (call it _<remote>_) with a matching name and
@@ -42,10 +42,8 @@ exactly one remote (call it _<remote>_) with a matching name and
4242
$ git checkout -b <branch> --track <remote>/<branch>
4343
------------
4444
+
45-
You could omit _<branch>_, in which case the command degenerates to
46-
"check out the current branch", which is a glorified no-op with
47-
rather expensive side-effects to show only the tracking information,
48-
if it exists, for the current branch.
45+
Running `git checkout` without specifying a branch has no effect except
46+
to print out the tracking information for the current branch.
4947
5048
`git checkout (-b|-B) <new-branch> [<start-point>]`::
5149

0 commit comments

Comments
 (0)