smorhaim
smorhaim

Reputation: 798

Why does checking out a git tag bring the wrong version of the code?

Step1: We have master, modify some files, commit, pull, tag, push --tags. Everything works.

Then we go to another computer and we do: git fetch, git tag -l shows the tagnames, git checkout -b tagname ... however the modified files from step 1 are not there... why?

Upvotes: 1

Views: 540

Answers (1)

hammar
hammar

Reputation: 139890

The problem is the -b option.

git checkout -b <new_branch> [<start_point>]

This means that you're creating a new branch called tagname. Since you didn't specify a start point, Git assumes you want it pointed at the current HEAD.

To simply check out a tag, just drop the -b:

git checkout tagname

If you want to create a new branch from the tag, give it a name and the correct starting point.

git checkout -b new_branch_name tagname

Upvotes: 3

Related Questions