George V. Reilly

Git: pruning unused branches

Ever had a Git repository where there’s an over­whelm­ing number of branches, most of which are surely abandoned? You run git branch --remote and you see dozens of unfamiliar branches. Where to begin?

Here’s an example for fly­ing­cloud:

$ git for-each-ref --sort=-committerdate \
    --format='%(committerdate:short) %(refname)' refs/heads refs/remotes
2016-12-29 refs/remotes/origin/master
2016-12-29 refs/remotes/origin/HEAD
2016-12-29 refs/heads/master
2016-12-11 refs/remotes/origin/0.1.x
2016-06-09 refs/remotes/origin/fix/salt-pip-version-problem-in-demo
2016-05-25 refs/remotes/origin/updates
2016-05-09 refs/remotes/origin/feature/documentation-improvements-3
2016-04-19 refs/remotes/origin/feature/developer-setup-example
2016-04-17 refs/remotes/origin/feature/travis-build
2016-03-16 refs/remotes/origin/feature/documentation-improvements-2
2016-03-06 refs/remotes/origin/feature/documentation-improvements-1
2016-03-06 refs/remotes/origin/feature/documentation-and-examples
2016-02-26 refs/remotes/origin/rtfd
2016-02-21 refs/remotes/origin/feature/metakube
2016-01-17 refs/remotes/origin/walk_tree

$ git branch --remote --merged master
  origin/HEAD -> origin/master
  origin/feature/documentation-improvements-1
  origin/feature/documentation-improvements-2
  origin/feature/travis-build
  origin/fix/salt-pip-version-problem-in-demo
  origin/master
  origin/rtfd
  origin/updates
blog comments powered by Disqus
Markdown Live Preview » « Review: Dr. Strange