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.
Heh. "Just Google it" answers we're never particular conversation lubricant as they are not now. But of course you are right we live in age of wonder once again.
I'm fairly certain that at least half of the people commenting (and all of the people who downvoted you) have over a decade of git muscle memory in their fingers. That's far faster than asking AI, and sometimes probably even faster than their terminal can print.
I promise you nobody is trying to show off. Git's CLI is notoriously inconsistent and verbose, and every GUI for it is always missing a ton of relevant features because it was designed for someone else's itch.
Now we have people like you trying to wedge AI into the discussion. I'm sorry dude. There's nothing to argue here. Git is the most important tool we have as developers. It's worth learning because the whole point is precise changes. We put up with the bad interfaces because it's otherwise just that good.
It's still specialized, but looking it up has gotten easier. It's better to use the right tool for the job. What's next, are you gonna tell ChatGPT to list your files too?
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!
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.
I often have a few dozen branches open at work, because I'm often waiting for reviews to go through but don't want to be blocked. I also often run little experiments in the background, like having an AI agent try to reliably reproduce a flake I saw in the CI (and then producing a fix for the reliably reproducer).
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.
When I'm working on a repository where the remote is shared (like a corporate GitHub repository where not everyone has their own GitHub fork) I tend to name all my branches like 'eru/<something>'. That way I can quickly find my work, and I can also confidently delete branches without worrying about stepping on other people's toes nor being stepped on by accident. I encourage co-workers to do the same, but haven't strictly required it from team members.
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
I have been using the `git lb` alias suggested by https://ses4j.github.io/2020/04/01/git-alias-recent-branches... (post written April 1st but not a joke) and quite enjoying it. Shows me the last 10 branches I worked on (very easy to edit the alias definition to get more or fewer than 10), sorted by date, most recent first. It's been handy in all sorts of situations, especially because one of our internal libraries needs a bugfix or a new feature every 3 months or so. So every time I cd into that repo, I have no clue what I did last, but `git lb` tells me right away.
When I get worried about my skill set or career going away from LLMs, I get hit with a post like this with huge traction describing something I’ve already found and solved for myself. It makes me realize: I’m probably ok for a while because of all these experiences and knowledge, and I’m quite shit at communicating something that’s obviously valuable to others.
This was one of the better usability changes I made to git, yes you should probably set it for yourself
51 comments
[ 0.22 ms ] story [ 24.5 ms ] threadI 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.
Even better than ChatGPT is just doing the thing on reflex. Not every manual step is necessarily a chore when you actually know what you're doing.
I promise you nobody is trying to show off. Git's CLI is notoriously inconsistent and verbose, and every GUI for it is always missing a ton of relevant features because it was designed for someone else's itch.
Now we have people like you trying to wedge AI into the discussion. I'm sorry dude. There's nothing to argue here. Git is the most important tool we have as developers. It's worth learning because the whole point is precise changes. We put up with the bad interfaces because it's otherwise just that good.
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.
[0] - https://github.com/paulirish/git-recent
alias git-hot-refs="git branch --sort=committerdate | tail"
> git config branch.sort committerdate
> You can also supply this on a one-off basis as git branch --sort committerdate.
These don't seem like hacks to me. What do you have in mind?
https://github.com/tyre/recent-branches
Enjoy!
This was one of the better usability changes I made to git, yes you should probably set it for yourself