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:

    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 branch prints this:


    You can select and copy them, then run pbpaste |xargs -n1 git retire to retire them all. Substitute pbpaste with whatever prints the clipboard contents to STDOUT.

  • gb

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?