TIL: Efficient Sorting of Git Branches
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