Purge All Releases

Ok so, is there any way to purge all the releases/tags at once?
I can do that buy deleting them one by one. But it will take so long to do the same for all the 140 releases. That’s why I’m asking. Thank you in advance

I use
empty-remote:

#!/bin/sh
if [ -z "$1" ]; then
  echo "$0 url-for-remote-git-repository-with-branches-or-tags-to-remove" >&2
  exit 1
fi
if command -v parallel >/dev/null; then
  dispatch() {
    parallel -I% --max-args 25 git push "$1" %
  }
else
  dispatch() {
    xargs -n10 git push "$1"
  }
fi
cd ~/code/empty
git ls-remote "$1" |perl -ne 'next if /HEAD|\{}/;s/^\S+\s+/:/;print'|dispatch "$1"

note ~/code/empty needs to be an empty git repository (git init ~/code/empty).

1 Like

I’m pretty nervous about that. But anyway thank you :heart:

:warning: This will kill all branches that aren’t the default branch.
:information_source: Add an echo before git push to see what it does.
You can change the next if /.../ code if you want to not delete certain other branches.

I use this code frequently (which is why it’s a real script). Basically I fork a repository and then immediately run this script against the fork. But since I’m usually using it against a fork, if I want a branch back, I can pull it from the original repository.

Would you mind checking this repo ?
And could you please instruct me, how to do that?
Thank you in advance

Destroying all tags (locally) and then updating your origin accordingly should do the trick without deleting any branches — GH releases are tag-based, so no tags no releases. Just ensure that your local close is set to track tags too.

1 Like

I’ll try it :slight_smile:

That worked actually,
I ran this command:

git tag | xargs git push origin --delete
1 Like

A great thanks to @jsoref and @tajmone :wink:
I’ll mark my reply as an answer to the topic.

1 Like