Live data from Hacker News

Sort branches by last commit date

ryangreenberg.com

31–40 of 56 posts

Re: Sort branches by last commit date

#31
post #2

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

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.

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.

Re: Sort branches by last commit date

#32
post #29

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

> Just configure git branch to sort by the last commit date:

> 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?

Re: Sort branches by last commit date

#33
post #29

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

Probably because most of the time you list branches you goal isn't to discover what exists, but to find the specific one you're looking for.

Re: Sort branches by last commit date

#34
post #2

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

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

I would hope so

Re: Sort branches by last commit date

#36
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.

Re: Sort branches by last commit date

#38
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

Re: Sort branches by last commit date

#39

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.

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/'. 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.

Re: Sort branches by last commit date

#40
I rarely care about the date of the commit on the branch to determine recency, I care about when I last switched to the branch.

This comment gets it correct https://news.ycombinator.com/item?id=49504860

I wrote my own version to do this nearly 10 years ago: https://github.com/amarshall/git-recent-branches

Post reply on HN