Skip to content

Instantly share code, notes, and snippets.

@artgillespie
Created September 5, 2017 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artgillespie/b8eb19e5d5af0033d0e94b3812a4c80d to your computer and use it in GitHub Desktop.
Save artgillespie/b8eb19e5d5af0033d0e94b3812a4c80d to your computer and use it in GitHub Desktop.
Branch maintenance
# display the oldest 25 branches based on most recent commit date that start with `art`
git for-each-ref --sort=committerdate --format="%(refname:short)%09'%(committerdate)'" --count=25 refs/heads/art
# delete the oldest 25 branches based on most recent commit date that start with `art`
git for-each-ref --sort=committerdate --format="%(refname:short)%09'%(committerdate)'" --count=25 refs/heads/art | cut -f 1 | xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment