Friday, March 7, 2025

9️⃣ Git Tags

 

9️⃣ Git Tags


In Git, tags are used to mark specific points in a repository's history, often for releases (like v1.0, v2.0). Tags are similar to branches but do not change—they are just references to specific commits.



🌍 Shape Your Future with AI & Infinite Knowledge...!!

🌐 Want to Generate Text-to-Voice, Images & Videos? 👉 http://www.ai.skyinfinitetech.com 📚 Read In-Depth Tech & Self-Improvement Blogs 👉 http://www.skyinfinitetech.com ▶ Watch Life-Changing Videos on YouTube 👉 https://www.youtube.com/@SkyInfinite-Learning 🔥 Transform Your Skills, Business & Productivity – Join Us Today! 🔥



🔹 Creating a Tag (git tag)

To create a tag, you first need to find the commit you want to tag.

1️⃣ Creating a Lightweight Tag

A lightweight tag is simply a reference to a commit without additional metadata.


git tag v1.0

This tags the latest commit as v1.0.


2️⃣ Creating an Annotated Tag

Annotated tags store extra information like the author's name, email, and date.


git tag -a v1.0 -m "Version 1.0 release"

Use -a to create an annotated tag and -m to add a message.


3️⃣ Creating a Tag for an Older Commit

If you need to tag a past commit, find its commit hash using:


git log --oneline

Then, create a tag for that commit:


git tag -a v1.0 <commit-hash>


🔹 Deleting a Tag (git tag -d)

If you created a tag by mistake or need to remove an old one, use:


git tag -d v1.0

This removes the tag locally, but it still exists in the remote repository.

To delete it from the remote repository:


git push origin --delete v1.0


🔹 Pushing and Fetching Tags

1️⃣ Pushing a Tag to Remote Repository

By default, tags are not pushed when you run git push. To push a specific tag:


git push origin v1.0

To push all tags at once:


git push --tags


2️⃣ Fetching Tags from Remote Repository

When you clone a repository, tags are not fetched by default. To fetch all tags:


git fetch --tags


3️⃣ Checking Available Tags

To list all tags in a repository:


git tag

For more details:


git tag -n


🔹 Best Practices for Using Git Tags

✅ Use annotated tags for official releases.
✅ Use lightweight tags for temporary references.
✅ Keep consistent naming conventions (e.g., v1.0, v1.1, release-2024).
✅ Always push tags to remote after creating them locally.





📚 Top 5 Books That Will Change Your Life!(Top 5 Life-Changing Books) 🚀


1️⃣ Atomic Habits – Build powerful habits and break bad ones!

👉 Get it here

2️⃣ The Psychology of Money – Master your financial mindset!

👉 Get it here

3️⃣ Think and Grow Rich – Unlock the secrets to wealth and success!

👉 Get it here

4️⃣ The Power of Your Subconscious Mind – Train your mind for success!

👉 Get it here

5️⃣ Rich Dad Poor Dad – Learn financial lessons the rich teach their kids!

👉 Get it here





No comments:

Post a Comment

Terraform State Deep Dive: Why it's Crucial and How to Manage It

Terraform State Deep Dive: Why it's Crucial and How to Manage It ...