Skip to content

Commit a4c0f96

Browse files
committed
doc: git-checkout: clarify git checkout <branch>
- Reduce use of jargon ("index", "HEAD") - Clarify that only identical files will be left unchanged, and that `git checkout` will fail rather than overwrite an unchanged file - Explain what `git checkout` with no arguments does in a more direct way Signed-off-by: Julia Evans <[email protected]>
1 parent 79d2d03 commit a4c0f96

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Documentation/git-checkout.adoc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ 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. Files which are
33+
identical in _<branch>_ and your current commit are left unchanged
34+
so that you can keep your uncommitted changes to those files.
35+
This will not overwrite uncommitted changes to a file: instead it
36+
will fail without making any changes.
3637
+
3738
If _<branch>_ is not found but there does exist a tracking branch in
3839
exactly one remote (call it _<remote>_) with a matching name and
@@ -42,10 +43,8 @@ exactly one remote (call it _<remote>_) with a matching name and
4243
$ git checkout -b <branch> --track <remote>/<branch>
4344
------------
4445
+
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.
46+
Running `git checkout` without specifying a branch has no effect except
47+
to print out the tracking information for the current branch.
4948
5049
`git checkout (-b|-B) <new-branch> [<start-point>]`::
5150

0 commit comments

Comments
 (0)