git | github

Delete All Local/Remote Git Tags

Remove all git tags from your local/origin git repository.

Abhith Rajan
Abhith RajanJune 02, 2022 · 2 min read · Last Updated:

On rare occasions, you may want to remove all local and remote git tags from your repository. For that, you can follow the below Recommended Steps.

In short, first, we are replacing the local tags with the remote tags, then removing all remote tags with reference to the local tags, and finally, removing all local tags.

1. Delete all local tags

git tag -d $(git tag -l)

2. Fetch all remote tags

git fetch

Retrieves all remote tags giving you a complete list of remote tags.

3. Delete All remote tags

git push origin --delete $(git tag -l)

Deletes the remote tags with reference to the local list.

4. Delete All local tags

git tag -d $(git tag -l)

Once again, deletes all local tags.

Unnecessary Details

One of the rare occasions to delete all tags in my case was, that we were maintaining a monorepo in Azure DevOps, and wanted to migrate it to GitHub, but in a repo per component manner. So,

  • First I did import the monorepo by following 👉 Code Migration From Azure DevOps to GitHub,
  • Then removed all other component’s code from the repo (git history is still dirty with other component’s old commits)
  • Re-configured the existing Azure pipeline triggers, i.e switched to a tag-based trigger. So, on each new release in GitHub, the connected Azure pipelines will run.

Now, the monorepo had so many tags including the tags of the other components. So, I wanted to remove all the tags from the repo before proceeding with the GitHub releases, and I did use the Recommended Steps above.

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub


Abhith Rajan

Written byAbhith Rajan
Abhith Rajan is a software engineer by day and a full-stack developer by night. He's coding for almost a decade now. He codes 🧑‍💻, write ✍️, learn 📖 and advocate 👍.
Connect

Is this page helpful?

Related ArticlesView All

Related VideosView All

7 strategies for end-to-end CI/CD governance

Learn how to use Project Views - GitHub Checkout

Learn how to use Project Fields - GitHub Checkout

Related Tools & ServicesView All

giscus.app

giscus

A comments widget built on GitHub Discussions.
rtyley.github.io

BFG Repo-Cleaner by rtyley

A simpler, faster alternative to git-filter-branch for deleting big files and removing passwords from Git history.