]> git.ipfire.org Git - thirdparty/git.git/commitdiff
doc: git-checkout: deduplicate --detach explanation
authorJulia Evans <julia@jvns.ca>
Wed, 10 Sep 2025 19:14:27 +0000 (19:14 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Sep 2025 21:32:04 +0000 (14:32 -0700)
From user feedback: several users say they don't understand the use case
for `--detach`. It's probably not realistic to explain the use case for
detached HEAD state here, but we can improve the situation.

Explain how `git checkout --detach` is different from
`git checkout <branch>` instead of copying over the description from
`git checkout <branch>`, since `git checkout <branch>` will be a
familiar command to many readers.

Signed-off-by: Julia Evans <julia@jvns.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-checkout.adoc

index aaff488929487f8414f663f1db4bf50029a9ba58..215fe4088990d098ff73758f709197506116657a 100644 (file)
@@ -66,16 +66,9 @@ uncommitted changes.
 `git checkout --detach [<branch>]`::
 `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
-       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.
-+
-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`).
+       The same as `git checkout <branch>`, except that instead of pointing
+       `HEAD` at the branch, it points `HEAD` at the commit ID.
+       See the "DETACHED HEAD" section below for more.
 +
 Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.