0
0
Gitdevops~30 mins

Tagging specific commits in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Tagging Specific Commits in Git
📖 Scenario: You are working on a project using Git for version control. You want to mark important points in your project's history by tagging specific commits. This helps you easily find those commits later, like marking chapters in a book.
🎯 Goal: Learn how to create a Git repository, make commits, add tags to specific commits, and list those tags.
📋 What You'll Learn
Create a Git repository
Make at least two commits
Tag a specific commit with a meaningful name
List all tags to verify
💡 Why This Matters
🌍 Real World
Tagging commits helps mark important versions like releases or milestones in software projects.
💼 Career
Knowing how to tag commits is essential for software developers and DevOps engineers to manage project versions and releases.
Progress0 / 4 steps
1
Initialize Git repository and create first commit
Initialize a new Git repository in the current folder using git init. Then create a file named file.txt with the text Hello World. Add this file to Git and commit it with the message Initial commit using git add file.txt and git commit -m "Initial commit".
Git
Need a hint?

Use git init to start the repository. Use echo to create the file. Then add and commit.

2
Create a second commit
Create a second commit by appending the text More content to file.txt. Then add and commit the changes with the message Second commit using git add file.txt and git commit -m "Second commit".
Git
Need a hint?

Use >> to append text to the file. Then add and commit again.

3
Tag the first commit
Create a tag named v1.0 on the first commit. Use git tag v1.0 <commit-hash> where <commit-hash> is the hash of the first commit. Find the first commit hash using git log --reverse --format=%H and use it in the tag command.
Git
Need a hint?

Use git log --reverse --format=%H to get commits from oldest to newest. Use head -n 1 to get the first commit hash.

4
List all tags to verify
List all tags in the repository using git tag to verify that the tag v1.0 exists.
Git
Need a hint?

Use git tag to see all tags.