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

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

Top comments (0)