WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Git · Intermediate · question 37 of 100

What is the purpose of ’git tag’, and how do you create and use tags in Git?

📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

In Git, a tag is a way to mark a specific commit with a label. Tags can be used to identify important milestones in a project’s history, such as releases, and they can be used to quickly reference specific commits.

Here’s how to create and use tags in Git:

Create a tag for the current commit using the git tag command.

    git tag v1.0.0

Verify that the tag was created successfully using the git tag command.

    git tag
    v1.0.0

Push the tag to the remote repository using the git push command with the –tags option.

    git push --tags

Check out a specific tag using the git checkout command.

    git checkout v1.0.0

This will switch your working directory to the commit that the tag points to.

Create an annotated tag with a message using the -a option and a message with the -m option.

    git tag -a v1.1.0 -m "Release version 1.1.0"

An annotated tag includes a message that can provide additional context about the tag.

View the details of a specific tag using the git show command.

    git show v1.1.0

This will display information about the commit that the tag points to, as well as the tag message (if the tag is annotated).

In summary, a tag is a way to mark a specific commit with a label in Git. Tags can be used to identify important milestones in a project’s history, such as releases, and they can be used to quickly reference specific commits. To create a tag, use the git tag command, and to push the tag to the remote repository, use the git push command with the –tags option. To check out a specific tag, use the git checkout command, and to view the details of a specific tag, use the git show command.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Git interview — then scores it.
📞 Practice Git — free 15 min
📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

All 100 Git questions · All topics