Skip to content

Commit 1f29915

Browse files
author
Thomas Hartmann
committed
Correct section on checking out tags
This commit updates the section on checking out tags by replacing the old text saying you can't really do it with a short paragraph explaining how to do it.
1 parent 7c78ac3 commit 1f29915

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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

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

212212
==== Checking out Tags
213213

214-
You can't really check out a tag in Git, since they can't be moved around.
215-
If you want to put a version of your repository in your working directory that looks like a specific tag, you can create a new branch at a specific tag with `git checkout -b [branchname] [tagname]`:
214+
You can check out a tag through the `git checkout` command the same way you would with a commit:
216215

217216
[source,console]
218217
----
219-
$ git checkout -b version2 v2.0.0
220-
Switched to a new branch 'version2'
221-
----
218+
$ git checkout 2.0.0
219+
Note: checking out '2.0.0'.
220+
221+
You are in 'detached HEAD' state. You can look around, make experimental
222+
changes and commit them, and you can discard any commits you make in this
223+
state without impacting any branches by performing another checkout.
224+
225+
If you want to create a new branch to retain commits you create, you may
226+
do so (now or later) by using -b with the checkout command again. Example:
227+
228+
git checkout -b <new-branch-name>
229+
230+
HEAD is now at 99ada87... Merge pull request #89 from schacon/appendix-final
222231
223-
Of course if you do this and do 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.
232+
$ git checkout 2.0-beta-0.1
233+
Previous HEAD position was 99ada87... Merge pull request #89 from schacon/appendix-final
234+
HEAD is now at df3f601... add atlas.json and cover image
235+
----

0 commit comments

Comments
 (0)