Skip to content

Commit 953f3d6

Browse files
author
J. Bruce Fields
committed
user-manual: more discussion of detached heads, fix typos
Nicolas Pitre pointed out a couple typos and some room for improvement in the discussion of detached heads. Signed-off-by: "J. Bruce Fields" <[email protected]> Cc: Nicolas Pitre <[email protected]>
1 parent e102d43 commit 953f3d6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Documentation/user-manual.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,16 @@ and git branch shows that you are no longer on a branch:
527527
------------------------------------------------
528528
$ cat .git/HEAD
529529
427abfa28afedffadfca9dd8b067eb6d36bac53f
530-
git branch
530+
$ git branch
531531
* (no branch)
532532
master
533533
------------------------------------------------
534534

535535
In this case we say that the HEAD is "detached".
536536

537-
This can be an easy way to check out a particular version without having
538-
to make up a name for a new branch. However, keep in mind that when you
539-
switch away from the (for example, by checking out something else), you
540-
can lose track of what the HEAD used to point to.
537+
This is an easy way to check out a particular version without having to
538+
make up a name for the new branch. You can still create a new branch
539+
(or tag) for this version later if you decide to.
541540

542541
Examining branches from a remote repository
543542
-------------------------------------------
@@ -1560,8 +1559,19 @@ $ git show master@{2} # See where the branch pointed 2,
15601559
$ git show master@{3} # 3, ... changes ago.
15611560
$ gitk master@{yesterday} # See where it pointed yesterday,
15621561
$ gitk master@{"1 week ago"} # ... or last week
1562+
$ git log --walk-reflogs master # show reflog entries for master
1563+
-------------------------------------------------
1564+
1565+
A separate reflog is kept for the HEAD, so
1566+
1567+
-------------------------------------------------
1568+
$ git show HEAD@{"1 week ago"}
15631569
-------------------------------------------------
15641570

1571+
will show what HEAD pointed to one week ago, not what the current branch
1572+
pointed to one week ago. This allows you to see the history of what
1573+
you've checked out.
1574+
15651575
The reflogs are kept by default for 30 days, after which they may be
15661576
pruned. See gitlink:git-reflog[1] and gitlink:git-gc[1] to learn
15671577
how to control this pruning, and see the "SPECIFYING REVISIONS"

0 commit comments

Comments
 (0)