Skip to content

Instantly share code, notes, and snippets.

@gnarmis
Last active August 29, 2015 14:01
Show Gist options
  • Save gnarmis/63016a8aad4f850e7a09 to your computer and use it in GitHub Desktop.
Save gnarmis/63016a8aad4f850e7a09 to your computer and use it in GitHub Desktop.
List Git Branches by Recency
#!/bin/bash
#
# Blame @gnarmis if this doesn't work
#
# Put this anywhere on your $PATH (~/bin is recommended). Then git will see it
# and you'll be able to do `git recent-branches`.
#
# Show top 5 most recent branches:
# $ git recent-branches | head -n 5
#
#
set -e
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname)' | sed 's/refs\/heads\///g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment