Git Git and GitHub

Managing Tags and Restoring Branches in Git

Posted: January 09, 2026 | Updated: January 09, 2026
Share: Twitter LinkedIn

Managing Tags and Restoring Branches in Git

Posted: December 03, 2025 | Updated: December 03, 2025

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.

⭐ What Are 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.


1. Creating Tags

You can create tags from your current branch, or from a specific branch you want to archive.


Create a Tag (PowerShell)

# Create a timestamped tag from the current branch
$tag = "v1.0-" + (Get-Date -Format "yyyyMMdd_HHmmss")
git tag $tag
git push origin $tag

Create a Tag from Another Branch

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

Why Use Tags?

  • 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

2. Restoring a Branch from a Tag

If you deleted a branch or simply want to rebuild an older version of your project, restoring from a tag is simple.


Restore a Branch from a Tag (PowerShell)

# 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

When Should You Restore from a Tag?

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

🧠 Tips & Best Practices

👍 Use Prefixes for Organization

Good examples:

  • archive/backup-v1-20240101_103000

  • release/v2.0.1

  • stable/2023-11-05

This keeps tags clean and searchable.

👍 Always Push Tags Explicitly

Tags do not push automatically:

git push origin --tags

👍 Tags Are Safe Snapshots

Even if you:

  • delete the branch

  • rename the branch

  • change main branch
    your tag will always preserve the snapshot.