Delete git tags local and remote.

git delete tags

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

git tag --list

# Matching a pattern
git tag --list 'v*'
# The above matches tags starting with the letter "v"
List all the tags, plus with matching pattern.

DELETE

Delete the tags in the local and remote branch.

Local

git tag -d TAG1 TAG2 TAG3

# or

git tag --delete TAG1 TAG2 TAG3
Delete tags in local branch.

Remote

git push origin -d TAG1 TAG2 TAG3

# or

git push origin --delete TAG1 TAG2 TAG3
Delete tags in remote branch.

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

Best!

Srini @ RoverHead

Thirumalaa Srinivas

Thirumalaa Srinivas