Skip to content

Instantly share code, notes, and snippets.

@jakub-g
Last active November 3, 2020 17:58
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 jakub-g/ca3500a70b517ea2c67905b1eaa20e6a to your computer and use it in GitHub Desktop.
Save jakub-g/ca3500a70b517ea2c67905b1eaa20e6a to your computer and use it in GitHub Desktop.
git-branches-sorted-by-date-print-last-commit-message.sh

Description

  • prints all local branches, one per line
  • sorted by most recently updated (last commit date); rebased = updated
  • shows last commit date + branch name + (different color) last commit message

Usage:

$ branches # prints all local branches (long output but it's still fast)
2020-11-03 PV-14100 #Last commit message from PV-14100
2020-10-30 POC_UPDATE_WEBPACK #Last commit message from POC_UPDATE_WEBPACK
2020-10-04 PV-9862 #Last commit message from PV-9862
2020-09-11 PV-8290 #Last commit message from PV-8290
...

$ branches | head -10 # show only 10 most recently updated
alias branches='git for-each-ref --sort=-committerdate --format="%(committerdate:short) %(refname:short) %(color:cyan) %(contents:subject)" refs/heads/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment