Update 01-chapter2.markdown - Added sub-section on checking out tags #397

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@drevicko
drevicko commented Apr 2, 2013

There doesn't seem to be any instructions or explanations about checking out tags, so I added a sub-section of the Tagging section.

@drevicko drevicko Update 01-chapter2.markdown
Added sub-section on checking out tags
6b6c41a
@jnavila jnavila commented on the diff Apr 2, 2013
en/02-git-basics/01-chapter2.markdown
@@ -873,6 +873,16 @@ You can also search for tags with a particular pattern. The Git source repo, for
v1.4.2.3
v1.4.2.4
+### Checking Out Tags ###
+
+To switch your repository to the state recorded in an existing tag is essentially the same as checking out a branch in your repository. If your repository has a tag named v1.4.2.2, you can run this:
@jnavila
jnavila Apr 2, 2013 Member

This sentence feels not right. Better rephrase it: "Switching.... is essentially the same as checking ..." ?

@jnavila
jnavila Apr 2, 2013 Member

Please backquote v1.4.2.2

@jnavila jnavila commented on the diff Apr 2, 2013
en/02-git-basics/01-chapter2.markdown
@@ -873,6 +873,16 @@ You can also search for tags with a particular pattern. The Git source repo, for
v1.4.2.3
v1.4.2.4
+### Checking Out Tags ###
+
+To switch your repository to the state recorded in an existing tag is essentially the same as checking out a branch in your repository. If your repository has a tag named v1.4.2.2, you can run this:
+
+ $ git checkout 'v1.4.2.2'
+
+Git will give you a message saying that you are in "detached HEAD state". If you make some changes and attempt to commit them, git doesn't know where to put them (ie: which branch to put them in). Tags are intended to be static place markers in your repositories development history, like product release versions, so typically you will not be wanting to change the state they point to.
@jnavila
jnavila Apr 2, 2013 Member

The general tense form is present in the book.

@GArik
Contributor
GArik commented Apr 4, 2013

There doesn't seem to be any instructions or explanations about checking out tags

It is said that tag is a pointer to a specific commit. And in chapter 2 all work is done in the master branch. Chapter 3 introduces branches concept and tells reader how to switch to some specific commit -- you just can't put anything like "is essentially the same as checking out a branch" here, because that topic is not yet explained at this point. And chapter 2 is not apropriate place to describe "detached HEAD state", chapter 6 is.

@drevicko
drevicko commented Apr 5, 2013

Fair enough, but perhaps there should be a mention of how to switch the repository to a tag, perhaps referring to a later section of the book for more detail.

I suspect my use case is not uncommon: I cloned an existing source repository and want to switch to a particular version.

@schacon
Member
schacon commented Oct 22, 2014

You can't really switch to a tag, you can just check out a state that looks like a tag. It's probably a better idea to create a new branch based on a tag or something. It really depends on why you're doing it, I suppose. I agree that encouraging people to check out into a detached HEAD state is probably not a great idea this early in the Git adventure.

I'll see if I can work in something in the 2nd edition.

@schacon schacon closed this Oct 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment