Open In App

Using Tags in Git

Last Updated : 15 Jul, 2025
Comments
Improve
Suggest changes
4 Likes
Like
Report
Tagging in GIT refers to creating specific points in the history of your repository/data. It is usually done to mark the release points. Two main purposes of tags are:
  • Make Release point on your code.
  • Create historic restore points.
You can create tags when you want to create a release point for a stable version of your code. You can also create tags when you want to create a historic point for your code that you can refer to in the future to restore your data. To create a tag we need to go through the following steps: Step 1: Checkout to the branch you want to create the tag.
 git checkout {branch name} 
Step 2: Create a tag with some name
 git tag {tag name} 
There are many more ways in which we create tags. Annotated Tags
 git tag -a {tag name} -m {some message} 
Step 3: See all the created tags.
 git tag
To see the details of the tag we can use
 git show {tag name} 
To see tags starting with some letters
 git tag -l "v2.*"
Step 4: Push tags to remote.
 
git push origin {tag name}
git push --tags
 
"git push --tags" will push all tags at once. Before After Step 5: Delete Tags. (locally)
git tag -d {tag name}
git tag --delete {tag name}
  
Step 6: Delete tags from remote
git push origin -d {tag name}
git push origin --delete {tag name}
git push origin :{tag name}
"git push origin -d {tag name}" can also delete tag locally and remote at the same time.
Suggested Quiz
5 Questions

Why are tags used in Git?

  • A

    To merge two branches

  • B

    To mark release or restore points in history

  • C

    To track untracked files

  • D

    To delete commit history

Explanation:

Tags mark important snapshots like releases or restore points, making it easy to reference a specific commit later.

Which command creates an annotated tag with a message?

  • A

    git tag {name}

  • B

    git tag -d {name}

  • C

    git tag -a {name} -m "message"

  • D

    git push --tags

Explanation:

git tag -a creates an annotated tag that stores the author, date, message, and metadata.

To view all existing tags in a repository, the command is:

  • A

    git show tags

  • B

    git list tags

  • C

    git tags

  • D

    git tag

Explanation:

git tag lists all tags in the repository.

Which command pushes all tags to the remote at once?

  • A

    git push origin tags

  • B

    git push --all

  • C

    git push --tags

  • D

    git pull tags

Explanation:

git push --tags uploads every tag in the local repo to the remote repository.

How do you delete a tag locally?

  • A

    git delete tag {name}

  • B

    git tag -d {name}

  • C

    git push origin :{name}

  • D

    git remove tag {name}

Explanation:

git tag -d <name> (or git tag --delete) removes a local tag only.

Quiz Completed Successfully
Your Score :   2/5
Accuracy :  0%
Login to View Explanation
1/5 1/5 < Previous Next >

Article Tags :

Explore