git retire
When I don't need a branch anymore, I move it to archive/ and delete it from the central repo using a crude alias. ~/.gitconfig:
…
[alias]
…
retire = !sh -c 'git branch --move $1 archive/$1 && git push --delete origin $1' -
…
Ways to compose it:
If you use a branch naming scheme, you might want to retire multiple branches in a row. Say,
git branchprints this:… feature/12-repair-bicycle/1-explore feature/12-repair-bicycle/2-explore feature/12-repair-bicycle/3-proposal …You can select and copy them, then run
pbpaste |xargs -n1 git retireto retire them all. Substitutepbpastewith whatever prints the clipboard contents to STDOUT.
Ways to make it better:
- Don't try to delete branches that aren't on
origin. - Don't hardcode the remote. – Maybe delete the branch from all remotes?