Sorting Git branches
Cassidy Williams
Posted on February 16, 2024
Normally when you run git branch
on a repository, you get your list of branches in alphabetical order, which can be very annoying if you have a lot of them (unless you have a very rigid naming system by ticket number or something).
You can change that now!
In your repo, if you do:
git branch --sort=-committerdate
This will sort all of your branches by the date of their last commit!
You can sort by:
authordate
committerdate
creatordate
objectsize
taggerdate
Plus, you can also do this globally if you want to always do it by one of these, like so:
git config --global branch.sort -committerdate
Or, you could set an alias:
git config --global alias.brcd "branch --sort=-committerdate"
Now go on and git committing!
💖 💪 🙅 🚩
Cassidy Williams
Posted on February 16, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
devchallenge Submission for the DevCycle Feature Flag Challenge: Feature Flag Funhouse
November 30, 2024