Skip to content

Instantly share code, notes, and snippets.

@meangrape
Created July 27, 2026 14:27
Show Gist options
  • Select an option

  • Save meangrape/da921ed60a553a5c9e22ae1d4852b752 to your computer and use it in GitHub Desktop.

Select an option

Save meangrape/da921ed60a553a5c9e22ae1d4852b752 to your computer and use it in GitHub Desktop.
List git branches in reverse chronological order
# List local branches by date
function gbL() {
git for-each-ref --sort=-committerdate refs/heads/ \
--format='%(refname:short)|%(committerdate:relative)|%(subject)' \
| gawk -F '|' '{ printf "%-30s | %-20s | %s\n", $1, $2, $3 }' | head -10
}
# List remote branches by date
function gbLr() {
git for-each-ref --sort=-committerdate refs/remotes/origin \
--format='%(refname:short)|%(committerdate:relative)|%(subject)' \
| gawk -F '|' '{ printf "%-30s | %-20s | %s\n", $1, $2, $3 }' | head -10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment