Wednesday 2 October 2019

Git: tagging old commits


By default ‘git tag’ command will create a tag on the commit that HEAD is pointing to.

We can create a tag to previous commits using below syntax.

Syntax
git tag -a {version_name} {snapshot_id} -m "{message}"

$git log --pretty=oneline
5d1e6966e845a4709372b9af02d3ac32ae8026f4 (HEAD -> master) Add project description
2c389dc281395917105cf51f48bcc20c27ba51f4 Add author details
a143c88dcab536c36a1509cbc0819bcd5e4602ce Add test line to readme.md
1dcf079f688877f16c8f54b1b9e57fba19216e84 (tag: v1.0) add description to readme.md
546599eaf071a6a634ca36a20047f5e3a3925337 (origin/master) Add readme.md file

Let’s create new tag to the second latest commit using below syntax.


git tag -a v1.1 2c389dc281395917105cf51f48bcc20c27ba51f4 -m "Added Author Details"
$git tag -a v1.1 2c389dc281395917105cf51f48bcc20c27ba51f4 -m "Added Author Details"
$
$git tag
v1.0
v1.1

Let’s push the commit v1.1 to github.

Syntax

git push origin {tagName}
$git push origin v1.1
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 16 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (7/7), 679 bytes | 679.00 KiB/s, done.
Total 7 (delta 0), reused 0 (delta 0)
To https://github.com/harikrishna553/gitTaggingDemo.git
 * [new tag]         v1.1 -> v1.1




Previous                                                    Next                                                    Home

No comments:

Post a Comment