asb 5 hours ago

Even better (IMHO!) is `git config branch.sort -committerdate` (note the `-`). This will sort newest committer date first.

  • pkaodev 5 hours ago

    I have this as an alias in my .zshrc!! Very handy

  • mmsc 2 hours ago

    `git config --global branch.sort -committerdate`

  • nulltrace 2 hours ago

    Rebase an old branch and it suddenly looks recent again. The rewritten tip gets a fresh committer date.

    • quuxplusone 1 hour ago

      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.

  • johnwheeler 30 minutes ago

    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.

ComputerGuru 4 hours ago

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!

Waterluvian 26 minutes ago

Sorting alphabetically never made sense and basically represents not trying to do something useful with the ordering of branches.

Trace88 1 hour ago

Such a small quality of life improvement. My `git branch` output is a graveyard sometimes, this would be handy.

dalton74 49 minutes ago

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.

tikhonj 20 minutes ago

Let's sort git branches by quality, better branches towards the top, slop at the bottom.

zahlman 4 hours ago

How many branches would you need to have to make this worthwhile?

  • jamietanna 4 hours ago

    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

  • woodruffw 3 hours ago

    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.

  • spike021 2 hours ago

    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.

mcdow 1 hour ago

yep, i have a little helper in my zshrc for this sort of thing:

alias git-hot-refs="git branch --sort=committerdate | tail"

monster_truck 4 hours ago

I just click on tower and open it, much better

woodruffw 3 hours ago

Another useful one if you have a large number of tags and want to see the most recently created ones first:

    git config --global tag.sort -creatordate

(`-creatordate` reverses the sort so that the newest come first.)

bewareofscams 4 hours ago

Or just have `jj log` custom-configured.

jeffbee 1 hour ago

Feels like the type of problem you could simply choose to not have in the first place (by not using git).