Lesson Completion
Back to course

Deleting or Moving Tags

Beginner
7 minutes4.7Git

The Hook (The "Byte-Sized" Intro)

Tags are designed to be permanent — that's the point. But sometimes you tag the wrong commit, or a tag name has a typo, or you need to retag after a last-minute fix. Git lets you delete and re-create tags, but it requires deliberate steps on both local and remote. The key: always update the remote too, or teammates will still see the old tag.

📖 What is Deleting or Moving Tags?

Deleting a tag removes the named reference. Moving a tag means deleting it and re-creating it on a different commit. Both operations must be done on local AND remote separately.

Conceptual Clarity

Operations:

GoalLocal CommandRemote Command
Delete a taggit tag -d v1.0.0git push origin --delete v1.0.0
Move a tagDelete + recreateDelete remote + push new
Rename a tagDelete old + create new nameDelete remote old + push new

Why it requires two steps: Tags exist independently on local and remote. Deleting locally doesn't touch the remote, and vice versa.

Real-Life Analogy

Moving a tag is like removing a label from one file folder and sticking it on another. But if copies of that label exist in other offices (remote repos), you need to update those too — they don't sync automatically.

Visual Architecture

flowchart TD MOVE["Move tag v1.0.0"] --> DEL_L["1. Delete local<br/>git tag -d v1.0.0"] DEL_L --> DEL_R["2. Delete remote<br/>git push origin --delete v1.0.0"] DEL_R --> CREATE["3. Recreate local<br/>git tag -a v1.0.0 NEW_SHA"] CREATE --> PUSH["4. Push new tag<br/>git push origin v1.0.0"] style MOVE fill:#1a1a2e,stroke:#e94560,color:#e94560 style PUSH fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb

Why It Matters

  • Tagging mistakes: Tagging the wrong commit happens — knowing how to fix it is essential.
  • Remote sync: Forgetting to update the remote is the most common tag management mistake.
  • Team communication: Moving a tag after others have fetched it can cause confusion.
  • CI/CD impact: A moved tag may re-trigger pipelines — coordinate with the team.

Code

bash
# ─── Delete a local tag ─── git tag -d v1.0.0 # Deleted tag 'v1.0.0' # ─── Delete a remote tag ─── git push origin --delete v1.0.0 # Or: git push origin :refs/tags/v1.0.0 # ─── Move a tag to a different commit ─── # Step 1: Delete locally git tag -d v1.0.0 # Step 2: Delete remotely git push origin --delete v1.0.0 # Step 3: Recreate on the correct commit git tag -a v1.0.0 def5678 -m "Release v1.0.0 (corrected)" # Step 4: Push the new tag git push origin v1.0.0 # ─── Force-move a tag (shortcut) ─── git tag -f v1.0.0 def5678 # ⚠️ Force-creates, overwrites the old one git push origin v1.0.0 --force # ─── Rename a tag ─── git tag -a v1.0.0 $(git rev-parse v1.0.0-typo)^{} -m "Corrected name" git tag -d v1.0.0-typo git push origin v1.0.0 git push origin --delete v1.0.0-typo

Key Takeaways

  • Deleting/moving tags requires updating both local and remote.
  • The safest approach: delete → recreate → push (4 steps).
  • git tag -f is a shortcut for force-overwriting, but requires --force on push.
  • Communicate with the team before moving tags they may have already fetched.

Interview Prep

  • Q: How do you delete a tag from both local and remote? A: git tag -d <tag> deletes locally. git push origin --delete <tag> deletes from the remote. Both commands are needed because tags exist independently in each repository.

  • Q: What should you consider before moving a tag that others have fetched? A: Other developers may have the old tag in their local repo. They'll need to delete and re-fetch it. Also, CI/CD pipelines may have triggered on the old tag. Communicate the change to the team and coordinate.

  • Q: Why might you need to force-push a tag? A: When you've re-created a tag locally with git tag -f (pointing to a different commit), the remote still has the old version. git push origin <tag> --force overwrites the remote's version with yours.

Topics Covered

Git TagsGit Fundamentals

Tags

#git#tags#delete#beginner-friendly

Last Updated

2026-02-13