Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use tags in Git?

Tags:

git

A tag in git from what I understand is just marking a particular commit with a name.

So say I release version 1.5, I create a tag 1.5

Now if a customer finds a bug, how do I go and 'checkout' that 1.5 codebase to my working directory?

I guess that I would perform the bug fix, then create another tag like 1.5.1.

Then I would potentially merge that code into the current version, right?

like image 496
mrblah Avatar asked Dec 27 '09 03:12

mrblah


3 Answers

Now if a customer finds a bug, how do I go and 'checkout' that 1.5 codebase to my working directory?

git checkout -b fix1point5 v1.5

I guess that I would perform the bug fix, then create another tag like 1.5.1.

[edit edit]
git add .
git commit
git tag v1.5.1 HEAD

Then I would potentially merge that code into the current version right?

git checkout master
git merge v1.5.1
like image 163
Randal Schwartz Avatar answered Nov 16 '22 10:11

Randal Schwartz


git tag <1.5> -a

Then push it with

git push --tags

I found that you can then find tags checkout using:

git tag -l
git checkout <tag>

Found more info on a previous SO post

like image 22
Alex Marcotte Avatar answered Nov 16 '22 09:11

Alex Marcotte


git checkout 1.5

This will check out the 1.5 tag to your working directory. Then you can make any fixes you like, and then make another tag for version 1.5.1.

After this, simply check out back to master (or whatever branch you are developing on), and perform the following command:

git merge 1.5.1

This will merge the changes you made to the latest version of your codebase.

like image 11
Veeti Avatar answered Nov 16 '22 10:11

Veeti