| ▲ | Sort branches by last commit date(ryangreenberg.com) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 points by speckx 5 days ago | 34 comments | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | asb 6 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Even better (IMHO!) is `git config branch.sort -committerdate` (note the `-`). This will sort newest committer date first. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | ComputerGuru 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | jbranchaud an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | metmac 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Huge fan of `git recent` [0] for this purpose. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | m4rtink an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I have been using something like this for 10+ years by this point - still wonder why it is not default or easier to do than a custom gitconfig/alias hack. :P | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | thr0waway001 24 minutes ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nice. I made myself pretty much the same command couple years ago but called it 'latestbranches'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | dalton74 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | cryptolobster an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TIL Git can do this without a shell script. I’ve been manually sorting through branches like an idiot | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Trace88 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Such a small quality of life improvement. My `git branch` output is a graveyard sometimes, this would be handy. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Waterluvian 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorting alphabetically never made sense and basically represents not trying to do something useful with the ordering of branches. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | rglover an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Nice. Will help solve some mysteries on older projects. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | tomtom1337 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | zahlman 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
How many branches would you need to have to make this worthwhile? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | mcdow 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
yep, i have a little helper in my zshrc for this sort of thing: alias git-hot-refs="git branch --sort=committerdate | tail" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | tikhonj 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Let's sort git branches by quality, better branches towards the top, slop at the bottom. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | bewareofscams 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Or just have `jj log` custom-configured. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | woodruffw 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | monster_truck 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I just click on tower and open it, much better | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | jeffbee 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Feels like the type of problem you could simply choose to not have in the first place (by not using git). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | matltc an hour ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Amazing what one can learn from rtfm | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||