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
Angular codebases. It used the following things.
- Code commit conventions for message formatting.
- Version bumping and change log with
- Setting up and/or updating
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.
- List all the tags meant for future releases.
- Delete them in the local branch.
- Delete them in the remote branch.
List all the tags
git tag --list # Matching a pattern git tag --list 'v*' # The above matches tags starting with the letter "v"
Delete the tags in the local and remote branch.
git tag -d TAG1 TAG2 TAG3 # or git tag --delete TAG1 TAG2 TAG3
git push origin -d TAG1 TAG2 TAG3 # or git push origin --delete TAG1 TAG2 TAG3
The above commands will come in handy in a lot of different situations.