> For the complete documentation index, see [llms.txt](https://hemantajax-2.gitbook.io/git-step-by-step/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hemantajax-2.gitbook.io/git-step-by-step/tag.md).

# Tag

2 types

1. light weight tags
2. annonated tags

## Check tag type

```
git cat-file -t <tag-name>
// Ex
git cat-file -t v1.0.0-rc1
// tag <- annotated tag
// commit <- light weight tag
```

## Tagging idea

```
v1.0.0-rc1
v1.0.0-rc2
v1.0.0-rc3
v1.0.0-alpha
v1.0.0-beta
v1.0.0
```

```
git tag v1.0.0-rc1  // will be associated with recent commit
// annotated tag - have Tagger:... info
git tag -a v1.0.0-rc1 -m "I am tag with more detail" (-a -> annotated)
git tag // list tags
git tag -l "v1.0.0*" // search tags

// see particular tag
git show v1.0.0-rc1
```

## Compare Tag

```
git diff|difftool v1.0.0-alpha v1.0.0-beta
```

## Update Tag

Moving tag to different commit ( may be recent commit )

```
git tag -a v1.0.0-beta -f(--force) <commit hash>
```

## Remove Tag

```
git tag v1.0.0-beta --delete
git push origin :v1.0.0-beta :v1.0.0-beta // Removed existing tag from repo
```

## Pushing Tag to github

```
git push origin --tags // Push all local tags to remote
git push origin --follow-tags // Push only annotated tags to remote
git push origin v1.0.0-rc1 // push only light weight tag
```

## Config to push annotated tag by default ( with commit - git push origin master)

```
git config --global push.followTags true
```

## Checkout Tag

You need to create a branch to acheive this

```
git checkout -b my-branch <tag-name>
// Ex- git checkout -b my-branch v1.0.0-alpha
// make changes & commit 
git checkout master
git merge my-branch
git branch -d my-branch (delete branch once you are done)
```
