Tags are one of the most useful features in Git when you want to mark important snapshots, create versioned releases, or archive branches you don’t want to keep active.
This guide explains how to create tags, push them to GitHub, and restore branches later using those tags.
A tag is a permanent label attached to a specific commit. Tags are commonly used for:
Creating release versions (v1.0, v2.0)
Archiving old branches safely
Marking stable snapshots
Storing backups without keeping the entire branch on GitHub
Tags never move; they always point to the same commit.
You can create tags from your current branch, or from a specific branch you want to archive.
# Create a timestamped tag from the current branch $tag = "v1.0-" + (Get-Date -Format "yyyyMMdd_HHmmss") git tag $tag git push origin $tag
Useful when archiving an old branch before deleting it:
git fetch origin old-branch:old-branch $tag = "archive/old-branch-" + (Get-Date -Format "yyyyMMdd_HHmmss") git tag $tag old-branch git push origin $tag
They are lightweight backups
They do not clutter your branch list
GitHub won’t suggest them in pull requests
Perfect for archived code or stable versions
If you deleted a branch or simply want to rebuild an older version of your project, restoring from a tag is simple.
# List tags git tag -l "archive/*" # Choose tag and restore branch $tag = "archive/old-branch-20250101_120000" # replace with your tag git checkout -b old-branch-restore $tag git push --set-upstream origin old-branch-restore
Restore a branch when:
You’ve deleted an old branch but need the code again
You want to inspect or reuse archived work
You want to recreate an older version of the app
You need to debug an issue from past releases
Good examples:
archive/backup-v1-20240101_103000
release/v2.0.1
stable/2023-11-05
This keeps tags clean and searchable.
Tags do not push automatically:
git push origin --tags
Even if you:
delete the branch
rename the branch
change main branch
your tag will always preserve the snapshot.
ยฉ 2024 Webapptiv. All rights reserved.