Pequeño script para limpiar branches ya mergeados y referencias que ya no existen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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