Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pequeño script para limpiar branches ya mergeados y referencias que ya no existen
#!/usr/bin/env bash
BRANCHES_TO_FILTER="master|development"
MERGED_BRANCHES=$(git branch --merged | egrep -v "(^\*|$BRANCHES_TO_FILTER)")
if [ "$MERGED_BRANCHES" == "" ]; then
echo "No hay branches sin mergear"
exit 0
fi
echo -e "Se eliminaran los siguientes branches.\n\n$MERGED_BRANCHES\n\nEstá seguro? "
read -n 1 -r REPLY
echo ""
if [[ $REPLY =~ ^[Ss]$ ]]; then
echo "Eliminando branches localmente"
echo $MERGED_BRANCHES | xargs git branch -d
echo "Eliminando branches remotos"
echo $MERGED_BRANCHES | xargs git push --delete origin
echo "Limpiando referencias que ya no existen en origin"
git remote prune origin
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.