Lightweight vs annotated
- Git course
- Intermediate
- Lesson 22/82
- 4 min
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.0You 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
const releaseTag = "";
// Komutu yazdırSample solution
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
git tag ____ v1.2.0 -m "Stable release"
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 |