Skip to content

Purge All Releases #23376

Purge All Releases #23376
Jul 15, 2021 · 8 answers

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

That worked actually,
I ran this command:

git tag | xargs git push origin --delete

Replies

8 suggested answers

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).

0 replies

I’m pretty nervous about that. But anyway thank you ❤️

0 replies

⚠️ This will kill all branches that aren’t the default branch.
ℹ️ 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.

0 replies

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

0 replies

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.

0 replies
tajmone:

Destroying all tags (locally) and then updating your origin accordingly should do the trick

I’ll try it :slight_smile:

0 replies

That worked actually,
I ran this command:

git tag | xargs git push origin --delete
0 replies
Answer selected

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

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants