Yes. This is what one wants, since if you have recently rebased it, you're clearly doing work with it. Meanwhile, branches you don't care to touch sink to the bottom of the list.
FYI/fwiw Fish shell autocompletes branches sorted by last commit date when writing out git commands. It also provides completions for commitish objects grouped by class, giving precedence to the usual targets first, with each group sorted by its own sort key. Handy!
It opens a fuzzy finder window showing the branches you have in the repo, sorted by recency. Also shows the latest committer and the date. Hit enter on the one you want to swap to it.
I've seen monorepos with over 10k active branches. But even at a smaller scale (10-100 branches), it becomes useful when manually stacking and/or rebasing, especially if you have a smaller terminal.
At my current job it's fairly frequent that I have 5+ active branches open for a repo. Not ideal and that's another topic, but it is nice to be able to sort branches because of that.
The best upgrade to these kinds of git branch scripts is piping them to fzf. I’ve been using this fbr one from the fzf repo. https://github.com/jbranchaud/dotfiles/blob/main/zshrc.local...
Even better (IMHO!) is `git config branch.sort -committerdate` (note the `-`). This will sort newest committer date first.
I have this as an alias in my .zshrc!! Very handy
`git config --global branch.sort -committerdate`
Rebase an old branch and it suddenly looks recent again. The rewritten tip gets a fresh committer date.
Yes. This is what one wants, since if you have recently rebased it, you're clearly doing work with it. Meanwhile, branches you don't care to touch sink to the bottom of the list.
Even better, "hey, chat GPT, list my branches by commit date."
I know that's not a popular answer, but I'm just trying to demonstrate the reality that this kind of knowledge isn't specialized anymore.
FYI/fwiw Fish shell autocompletes branches sorted by last commit date when writing out git commands. It also provides completions for commitish objects grouped by class, giving precedence to the usual targets first, with each group sorted by its own sort key. Handy!
Sorting alphabetically never made sense and basically represents not trying to do something useful with the ordering of branches.
Huge fan of `git recent` [0] for this purpose.
[0] - https://github.com/paulirish/git-recent
Spoiler it’s fzf under the hood. But it’s perfect and simple.
Such a small quality of life improvement. My `git branch` output is a graveyard sometimes, this would be handy.
Our team's `git branch` output is a graveyard. Sorting by last commit would be a godsend for quickly identifying active work and stale branches.
I love this little fzf bash function that I wrote a few years ago: https://gist.github.com/thomasaarholt/141df779f3f16b641701b4...
It opens a fuzzy finder window showing the branches you have in the repo, sorted by recency. Also shows the latest committer and the date. Hit enter on the one you want to swap to it.
Let's sort git branches by quality, better branches towards the top, slop at the bottom.
How many branches would you need to have to make this worthwhile?
At any time I'm working across 5-30 branches (some when I'm reviewing other folks' code) so it's handy to see my latest branches
I've seen monorepos with over 10k active branches. But even at a smaller scale (10-100 branches), it becomes useful when manually stacking and/or rebasing, especially if you have a smaller terminal.
At my current job it's fairly frequent that I have 5+ active branches open for a repo. Not ideal and that's another topic, but it is nice to be able to sort branches because of that.
yep, i have a little helper in my zshrc for this sort of thing:
alias git-hot-refs="git branch --sort=committerdate | tail"
I just click on tower and open it, much better
Another useful one if you have a large number of tags and want to see the most recently created ones first:
(`-creatordate` reverses the sort so that the newest come first.)
Or just have `jj log` custom-configured.
Feels like the type of problem you could simply choose to not have in the first place (by not using git).