Skip to content

Instantly share code, notes, and snippets.

@jbruggem
Created May 17, 2019 20:20
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 jbruggem/17780f84964b0f52688a95c4e5d880fd to your computer and use it in GitHub Desktop.
Save jbruggem/17780f84964b0f52688a95c4e5d880fd to your computer and use it in GitHub Desktop.
Prune git repository branches
#!/bin/bash
cd $(dirname $0)
find -name .git -type d \
| xargs -i dirname "{}" \
| xargs -i bash -c '
cd {};
echo -e "\n\n==========="
echo -e " {} "
echo -e "==========="
git remote prune origin;
'"
git branch -vv | grep 'origin/.*: gone]' | awk '{print \$1}' | xargs -l1 -I## git branch -d '##';
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment