# Git alias for deleting merged local branches ## Setup Add this to your `.gitconfig` file. ```ini [alias] cleanup = !git branch --merged | grep -v \"\\*\" | grep -v \"\\+\" | grep -v main | grep -v master | grep -v dev | xargs -r -p git branch -D ``` ## Usage Run `git cleanup`, after the prompt, enter `y` to confirm, and it will automatically delete all the merged branches in your repository. This will not delete the following branches: - `main` - `master` - `dev` - Current `HEAD` - Branches checked out in a worktree