// https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit Use --sort=-commiterdate option of git for-each-ref using git branch git branch --sort=-committerdate