Skip to content

Instantly share code, notes, and snippets.

@Denton-L
Created April 27, 2019 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Denton-L/3f1b0f4bf1e91ce2e22d9156441462f4 to your computer and use it in GitHub Desktop.
Save Denton-L/3f1b0f4bf1e91ce2e22d9156441462f4 to your computer and use it in GitHub Desktop.
clear-stale.sh
#!/bin/sh
git ls-remote --heads "$1" |
cut -f2 |
sed -e 's|refs/heads/||' |
while read b
do
if [ `git rev-list --count "$2".."$1/$b"` -eq -0 -a "$b" != "$2" ]
then
echo $b
fi
done |
xargs git push --delete "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment