TIL: Efficient Sorting of Git Branches

What was the name of that branch again? Explore how to effortlessly sort Git remote branches by committer date.

About 1 min reading time

In Git, branches are sorted alphabetically by default. This is convenient when you remember the branch name, but it's not always the most practical approach. Fortunately, the sorting order can be customized to display branches with the latest changes first:

git branch --sort=-committerdate

Optionally, -r can be added to search for a remote branch. This is particularly useful when looking for a branch previously worked on with a teammate.

I have set this as the default in my personal .gitconfig:

[branch]
    sort = -committerdate

This post is based on my opinion and experience. It is based on what worked for me in my context. I recognize, that your context is different.
The "Just Sharing" Principle