Tags in Git (and GitHub) are super useful when you want to mark specific points in your project's history—like a stable release or a major update. Creating a tag is like putting a sticky note on a particular commit, so you or others can easily reference it later.
1. Create a Tag Using Git (Command Line)
Lightweight Tag:
git tag v1.0
Annotated Tag (recommended):
git tag -a v1.0 -m "Release version 1.0"
The -a flag creates an annotated tag with metadata like the tagger’s name, date, and a message.
2. Push Tag to GitHub
By default, tags aren't pushed with git push, so you need to do this:
git push origin v1.0
Or push all tags:
git push --tags
3. Create a Tag via GitHub Web UI
- Go to your repository on GitHub.
- Click on "Releases" > "Draft a new release".
- Enter a tag name (you can create a new one).
- Choose the target commit and fill in release notes.
- Click "Publish release".
So, whether you prefer the command line or GitHub’s UI, tagging is a great way to manage releases and track progress. It’s especially helpful when working on collaborative projects or using CI/CD pipelines.