CodeBlanks Logo Icon CodeBlanks

Lightweight vs annotated

Learn the difference between lightweight and annotated tags.

Lightweight Tags

A lightweight tag is a simple name assigned to a commit. It does not contain additional metadata such as an annotation, tag message, or tagger information.

git tag v1.0.0

You can use a lightweight tag when you need a quick and simple marker.

Annotated Tags and Messages

An annotated tag stores more information than a simple name assigned to a commit. It includes metadata such as the tagger, date, and annotation message.

git tag -a v1.0.0 -m "First stable release"

-a creates an annotated tag, while -m specifies its message. It is useful for documenting releases.

Practice Prepare an Annotated Tag Command

Assign the git tag -a v1.3.0 -m "Production release" command to the releaseTag variable. Print the command.

Starter code

terminal
const releaseTag = "";

// Komutu yazdır

Sample solution

terminal
const releaseTag = "git tag -a v1.3.0 -m \"Production release\"";

console.log(releaseTag);

Expected output

git tag -a v1.3.0 -m "Production release"

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which command creates a lightweight tag?

  • git tag -a v1.0.0 -m "Release"
  • git tag v1.0.0 Correct answer
  • git push --tags
  • git commit -m "v1.0.0"

Explanation: Running git tag v1.0.0 without additional options creates a lightweight tag.

2 Create an Annotated Tag

Question
git tag ____ v1.2.0 -m "Stable release"
Answer
git tag -a v1.2.0 -m "Stable release"

Explanation: The -a option creates an annotated tag. An annotation message can be added with the -m option.

3 Compare Tag Types

Term Meaning
Lightweight Simple commit marker
Annotated Tag containing extra metadata
-a Annotated tag option
-m Specifies the tag message

All lessons in Intermediate

20 Intermediate final

  1. Branch management
  2. Rebase
  3. Conflict
  4. PR flow