Skip to content

Instantly share code, notes, and snippets.

@gionniboy
Last active March 2, 2021 10:28
Show Gist options
  • Select an option

  • Save gionniboy/0b0452cec9c153c64230d78629ec5647 to your computer and use it in GitHub Desktop.

Select an option

Save gionniboy/0b0452cec9c153c64230d78629ec5647 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd $1
echo Pulling branches
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
echo Cleaning
for BRANCH in $(git branch --merged| egrep -v "(^\*|master|develop)")
do
git branch -d $BRANCH
git push --delete origin $BRANCH
done
echo Purging from remote
git remote prune origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment