delete merged branches
After some months there are too many old branches. Time to clean up.
This deletes all branches that are fully merged. It only deletes local branches.
❯ git branch --merged \
| grep -Pv '^\s*(\*|master|main|staging)' \
| xargs -r git branch -d
There will still be several branches left that are not merged yet. No script can decide whether they can be deleted or not.
Use git push origin --delete branch-name to delete the remote branch itself. git branch -rd
origin/branch-name only deletes your local remote-tracking ref.