Lesson 51 +15 XP

Git Tagging

Git Tagging

A tag marks a specific commit with a name, usually a version number like v1.0 or v2.4.1.

Why tag?

  • Mark release versions of your project.
  • Give important commits a name that is easy to remember.
  • Let people check out exactly the code from a release.

List tags

git tag

Create a tag

git tag v1.0

This tags your current commit with v1.0.

Tag a specific commit

git tag v1.0 abc123

This tags commit abc123 instead of the current one.

Annotated tags

git tag -a v1.0 -m "First release"

Annotated tags store extra info: the tagger's name, date, and a message. Lightweight tags are just a pointer.

Show a tag's commit

git show v1.0

Share tags with the remote

Tags are not pushed automatically:

git push origin v1.0

TL;DR

  • Tags name specific commits, usually for releases.
  • git tag v1.0 tags the current commit.
  • -a creates an annotated tag with a message.
  • Push tags with git push origin v1.0.