Skip to content

Latest commit

 

History

History
192 lines (119 loc) · 2.37 KB

File metadata and controls

192 lines (119 loc) · 2.37 KB

🏷️ Git Tag (Version Marking)

Mark important commits like releases, versions, and milestones.


📌 What Is Git Tag?

A tag is:

A label pointing to a specific commit.


🧠 Why Use Tags?

  • mark releases
  • track versions
  • easy rollback
  • deployment reference

🗺️ Example

A --- B --- C --- D
        ↑
      v1.0 tag

🧱 Types of Tags


1. Lightweight Tag

git tag v1.0

2. Annotated Tag

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

🧠 Difference

Lightweight Annotated
simple pointer full object
no metadata includes message, author

🧱 Common Commands


List tags

git tag

Show tag

git show v1.0

Push tag

git push origin v1.0

Push all tags

git push origin --tags

Delete tag

git tag -d v1.0

🧠 Internal Behavior

Tag → pointer to commit
Annotated tag → separate object

🧪 Real-World Scenario

v1.0 → first release
v1.1 → bug fixes
v2.0 → major update

🚨 Common Mistakes

  • forgetting to push tags
  • mislabeling versions

✅ Best Practices

  • use semantic versioning
  • prefer annotated tags
  • tag releases only

🎤 Interview Questions

What is a tag?

Pointer to a commit.


Difference between lightweight and annotated?

Annotated stores metadata.


Why use tags?

For versioning and releases.


🧪 Practice Lab

git tag -a v1.0 -m "release"
git push origin v1.0

🎯 Final Takeaway

Tags help you:

  • track versions
  • manage releases
  • simplify deployment

👉 Next Step

➡️ 06-git-hooks.md