Skip to content

Instantly share code, notes, and snippets.

@fhgbaguidi
Created January 9, 2023 09:19
Show Gist options
  • Save fhgbaguidi/9caebfe211ff33f3a89d0bb0ea368588 to your computer and use it in GitHub Desktop.
Save fhgbaguidi/9caebfe211ff33f3a89d0bb0ea368588 to your computer and use it in GitHub Desktop.
Delete all GitHub releases / tags
# Install GH cli
https://github.com/cli/cli#installation
# set GH_TOKEN env var
export GH_TOKEN=<<your_PAT_with_repo_access>>
# delete releases
$ gh release list | sed 's/|/ /' | awk '{print $1, $8}' | while read -r line; do gh release delete -y "$line"; done
$ gh release # list gets a list of releases as a table.
$ sed 's/|/ /' | awk '{print $1, $8}' # singles out the first column provided by the table
$ while read -r line; do gh release delete -y "$line"; done # ran the delete command for each result
# delete remote tags
$ git fetch
$ git tag -l | xargs -n 1 git push --delete origin
# delete local tags
git tag -d $(git tag -l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment