Reputation: 979
I want to delete all tags from production git repo with the tags that include "_TEST".
#!/bin/bash
COMMITS_TO_REMOVE=$(git ls-remote [email protected]:REPONAME | grep _test | cut -f1)
COMMITS_TO_REMOVE_NO_CRLF=$(echo "$COMMITS_TO_REMOVE" | tr '\n' ' ')
for c in $COMMITS_TO_REMOVE_NO_CRLF
do
git tag -d $c;
git push origin $c;
done;
but:
1) the COMMITS_TO_REMOVE_NO_CRLF isn't split by the spaces when running "for c in ..."
2) when I tried to push back the tags it didn't take.
ideas ?
Upvotes: 1
Views: 80
Reputation: 60255
You don't need COMMITS_TO_REMOVE_NO_CRLF
, bash takes newlines as whitespace.
You can delete the tags and, since at least 1.7, push the deletes in big batches with xargs
.
Combining,
commits=$(git ls-remote $remote | sed -n '/_test[^^]*$/ s,.*refs/tags/,,p')
echo "$commits" | xargs tag -d
echo "$commits" | xargs git push --delete [email protected]:repo
Upvotes: 1