How to change git branch output order

Viewed 4518

When I type git branch, I receive a list of branches that appear to be sorted alphabetically instead of being sorted by their creation time.

Is there a way to make the output of git branch sorted by date?

3 Answers

Stujo's answer is my favorite, but I wanted to go one step further and make sort by committer date my default git branch behavior. Here's how:

git config --global branch.sort -committerdate

Remove the - before committerdate to sort the other way.

Now git branch will always be sorted by date!

As of git 2.7.0 this will work:

git branch --sort=-committerdate
Related