Skip to content

Instantly share code, notes, and snippets.

View zepadovani's full-sized avatar

José Henrique Padovani Velloso zepadovani

  • Universidade Federal de Minas Gerais
  • Belo Horizonte, Brazil
  • 05:01 (UTC -03:00)
View GitHub Profile
@zepadovani
zepadovani / .gitconfig
Created October 22, 2025 11:59
~/.gitconfig alias for deleting remote and local branches of a repository (you can inform a series of branches and it will check locally and in remote
[alias]
cleanup = "!f() { for BRANCH in \"$@\"; do echo \"\n--- Executing cleanup for branch: $BRANCH ---\"; LOCAL_DELETED=0; REMOTE_DELETED=0; if git branch -d \"$BRANCH\" 2>/dev/null; then LOCAL_DELETED=1; elif git branch -D \"$BRANCH\" 2>/dev/null; then LOCAL_DELETED=1; fi; if git push origin --delete \"$BRANCH\" 2>/dev/null; then REMOTE_DELETED=1; fi; echo \"Cleanup report for branch '$BRANCH':\"; if [ $LOCAL_DELETED -eq 1 ]; then echo \" - [SUCCESS] Local branch deleted.\"; else echo \" - [SKIPPED] Local branch did not exist or was not deleted.\"; fi; if [ $REMOTE_DELETED -eq 1 ]; then echo \" - [SUCCESS] Remote branch deleted (origin/$BRANCH).\"; else echo \" - [SKIPPED] Remote branch did not exist or was not deleted.\"; fi; done; }; f"