In git, how can I efficiently delete all refs matching a pattern?

Viewed 624

I have over time archived a bunch of build tags in refs/builds/archived/* and I now want to delete them to recover some space and reduce total object count (over 50k annotated git tags are stored there).

It would appear that the only way to do this is like so:

git show-ref\
 | awk '/refs\/builds\/archived\/[^\/]*$/ { print "git update-ref -d "$2}'\
 | sh

This is extremely slow. Also, doing this appears to slow down any git fetches done from the repo until I get to run git gc on it.

1 Answers
Related