Wednesday 2 October 2019

Git: tagging


Git tags are used to refer specific point in git history. Once a tag is created, you can refer the snapshot of the branch at tag creation time whenever you want.

Create a github branch
Go to ‘https://github.com/’ and create new repository.

Clone the repository
$ git clone https://github.com/harikrishna553/gitTaggingDemo.git
Cloning into 'gitTaggingDemo'...
warning: You appear to have cloned an empty repository.

Add readme.md to the repository and push the changes to remote
$cd gitTaggingDemo/
$
$touch readme.md
$
$git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

 readme.md

nothing added to commit but untracked files present (use "git add" to track)
$
$git add .
$git commit -m "Add readme.md file"
[master (root-commit) 546599e] Add readme.md file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.md
$
$git push origin HEAD
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 215 bytes | 215.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/harikrishna553/gitTaggingDemo.git
 * [new branch]      HEAD -> master


Add some content to readme.md file, commit the changes
$cat readme.md 
# git tag demo
$
$git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

 modified:   readme.md

no changes added to commit (use "git add" and/or "git commit -a")
$
$git add .
$git commit -m "add description to readme.md"
[master 1dcf079] add description to readme.md
 1 file changed, 1 insertion(+)

Create a tag
Use below syntax to create a tag.

git tag <tagname>
$git tag v1.0
$
$git tag
v1.0

Push tags to remote

Syntax

git push origin {tagName}
$git tag
v1.0
$
$git push origin v1.0
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 264 bytes | 264.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/harikrishna553/gitTaggingDemo.git
 * [new tag]         v1.0 -> v1.0



Click on ‘release’ link.


Under the tags section, you can see the tag that we created. You can download the entire repository at given tag in zip format.



Previous                                                    Next                                                    Home

No comments:

Post a Comment