Tags are like branches, except they don't usually change

There are two types of git tags - annotated and lightweight

  • We’re going to only cover lightweight tags today (you’ll see these more often)
  • A lightweight tag is like a branch that does not change
    • Pointer to a specific git-ref.
    • Unlike annotated tags, it is not a full object in the Git DB (not annotated, not-checksummed, not signed, no metadata about the creator)
  • Lightweight tags - under the covers



Ensure your current directory is that of the cloned repository in the previous practical.

Creating a tag

# On a branch or any kind of git-ref
git tag v1.2.3-your-name

# Check filesystem (ls .git/refs/tags)
# Git does not push tags by default to a remote
# Or `git push --tags`
git push origin v1.2.3-your-name

Now create another tag v99.0.0 before moving onto the next part

# Checkout a tag
git checkout v99.0.0

# Create a branch from a tag
git checkout -b version-nine-nine v99.0.0

# Delete tags /!\ Careful now  /!\
# Local only
git tag -d v99.0.0

# Delete from remote
git push origin :refs/tags/v99.0.0

# A little bit about annotated tags
git tag -s v0.99.0-annotated -m "my tag v0.99.0-annotated"
git show v0.99.0-annotated

Viewing a tag

# LW tags are files on disk with a pointer to a commit
ls .git/refs/tags/

# Cat to reveal pointer to a commit
cat git/refs/tags/v99.0.0

# Show this commit
git show 659220