Skip to content

Instantly share code, notes, and snippets.

@mario21ic
Last active November 16, 2016 15:17
Show Gist options
  • Save mario21ic/f447f98cddba8003769ed8374efe7861 to your computer and use it in GitHub Desktop.
Save mario21ic/f447f98cddba8003769ed8374efe7861 to your computer and use it in GitHub Desktop.
Remove all unnecessary branches with prefix local and remote
#!/bin/bash
# Prefijo de las ramas a eliminar
PREFIX="APT"
# Sincroniza
git fetch origin --prune
# Limpia localmente
git branch|grep $PREFIX|xargs git branch -D
# Limpia remotamente
branchs_remote=$(git branch -r|grep $PREFIX|awk '{print substr($1,8) }')
for branch in $branchs_remote
do
git push origin --delete $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment