Checking out tags on Git

Viewed 1578

I was going through some git internals and came across tags and how they're stored internally. In the Git SCM site I found the following:

Checking out Tags

You can’t really checkout a tag in Git, since they can’t be moved around. 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]:

git checkout -b version2 v2.0.0

Switched to a new branch 'version2'

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.

I have the following doubts:

  1. Why can't we check out tags? Can't we traverse the Git TAG to make HEAD point to the commit pointed to by the tag?
  2. Can we create a new commit which will then point to the commit pointed to by tag as the parent?
  3. It is said that if we create a new branch from the tag and commit, it'll be slightly different. What difference are they talking about? Won't the new commit (assuming nothing has changed) refer to the tagged commit as its parent with everything else (trees & blobs) remaining the same?

Thank you.

EDIT:
I'm referring to cases where HEAD and the tag point to different commits.

1 Answers
Related