Skip to content

Commit fc4ec46

Browse files
author
Thomas Hartmann
committed
Implement clarification about detached HEAD state
This commit implements changes discussed with @ben on pull request #786 to make the text more easily understandable for everyone.
1 parent 1f29915 commit fc4ec46

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

book/02-git-basics/sections/tagging.asc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ Now, when someone else clones or pulls from your repository, they will get all y
211211

212212
==== Checking out Tags
213213

214-
You can check out a tag through the `git checkout` command the same way you would with a commit:
214+
If you want to view the versions of files a tag is pointing to, you can do a git checkout, though this puts your repository in ``detached HEAD'' state, which has some ill side effects:
215215

216216
[source,console]
217217
----
@@ -232,4 +232,14 @@ HEAD is now at 99ada87... Merge pull request #89 from schacon/appendix-final
232232
$ git checkout 2.0-beta-0.1
233233
Previous HEAD position was 99ada87... Merge pull request #89 from schacon/appendix-final
234234
HEAD is now at df3f601... add atlas.json and cover image
235-
----
235+
----
236+
237+
In ``detached HEAD'' state, if you make changes and then create a commit, the tag will stay the same, but your new commit won't belong to any branch and will be unreachable, except for by the exact commit hash. Thus, if you need to make changes—say you're fixing a bug on an older version, for instance—you will generally want to create a branch:
238+
239+
[source,console]
240+
----
241+
$ git checkout -b version2 v2.0.0
242+
Switched to a new branch 'version2'
243+
----
244+
245+
If you do this and make a commit, your `version2` branch will be slightly different than your `v2.0.0` tag since it will move forward with your new changes, so do be careful.

0 commit comments

Comments
 (0)