Skip to content

Instantly share code, notes, and snippets.

@rosskirkpat
Created August 16, 2022 17:10
Show Gist options
  • Save rosskirkpat/d5036a0754162c529f64f0e67aa29d7c to your computer and use it in GitHub Desktop.
Save rosskirkpat/d5036a0754162c529f64f0e67aa29d7c to your computer and use it in GitHub Desktop.
bash: how to re-push a git tag that has already been published
#!/bin/bash
# set your TAG as a variable to avoid typos
TAG=v2.6.7
REPO=rancher/cli
# checkout v2.6 (main) branch
git clone https://github.com/$REPO.git
cd ${REPO#*/}
# verify you have latest changes
git fetch origin
git pull
# check that your latest commit matches what github shows
git log --oneline
# delete the local tag for v2.6.7
git tag -d $TAG
# Create the tag again for v2.6.7
git tag $TAG
# Delete the tag on remote
git push origin :$TAG
# Create the tag on remote
git push origin $TAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment