Skip to content

Instantly share code, notes, and snippets.

@calvinjuarez
Last active June 16, 2016 18:48
Show Gist options
  • Save calvinjuarez/4089f55401bab2d8741221713e20f086 to your computer and use it in GitHub Desktop.
Save calvinjuarez/4089f55401bab2d8741221713e20f086 to your computer and use it in GitHub Desktop.
Git Alias for Listing Local or Remote Branches by Last Modified Date
[alias]
branch-latest = "! git-branch-latest() { if [[ $1 == \"-r\" ]]; then for branch in `git branch -r | grep -v HEAD`;do echo `git show -s --oneline --format=\"%Cblue%ci%Creset\" $branch | head -n 1` \"\t$branch\"; done | sort -r; else git for-each-ref --sort=-committerdate --format=\"%(color:blue)%(committerdate:iso)%(color:reset)%09%(refname:short)\" refs/heads/; fi }; git-branch-latest"
@calvinjuarez
Copy link
Author

calvinjuarez commented Jun 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment