DEV Community

Cover image for Delete git tags local and remote.
Sri-Ni, Thirumalaa Srinivas
Sri-Ni, Thirumalaa Srinivas

Posted on • Originally published at roverhead.com

1

Delete git tags local and remote.

These may come in real handy when setting up code commit infrastructure.


I was setting up code commit conventions, change log and release infrastructure in React & Angular codebases. It used the following things.

  • Code commit conventions for message formatting.
  • Version bumping and change log with standard-release.
  • Setting up and/or updating README.md and CONTRIBUTING.md.

While doing this, many tags were created for testing in the branch. I wanted to avoid having all those future tags in the repo.

Hence, I needed to do the following.

  1. List all the tags meant for future releases.
  2. Delete them in the local branch.
  3. Delete them in the remote branch.

LIST

List all the tags

List all the tags, plus with matching pattern.

git tag --list

# Matching a pattern
git tag --list 'v*'
# The above matches tags starting with the letter "v"
Enter fullscreen mode Exit fullscreen mode

DELETE

Delete the tags in the local and remote branch.

Local

git tag -d TAG1 TAG2 TAG3

# or

git tag --delete TAG1 TAG2 TAG3
Enter fullscreen mode Exit fullscreen mode

Remote

git push origin -d TAG1 TAG2 TAG3

# or

git push origin --delete TAG1 TAG2 TAG3
Enter fullscreen mode Exit fullscreen mode

The above commands will come in handy in a lot of different situations.

Best!

Srini @ RoverHead

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay