gg2 is a command line tool for doing things with Git branches, faster. One of the convenient commands is gg2 branches.
It lists your recent branches, sorted by committer-date and for each branch it displays a human-friendly date distance and whether it's already been merged. Looks like this:
Turns out, for large repos figuring out which branches have already been merged is quite slow. For example, in this repo it takes half a second to list all merged branches:
$ git branch --all --merged | wc -l
669
$ time git branch --all --merged 1>/dev/null
real 0m0.490s
user 0m0.460s
sys 0m0.030s
The problem was that gg2 branches also does multiple other git branch listing commands to get information. In particular: get the current branch, figure out the default branch, a list of branch committer dates, and a list of merged branches.
All of these async operations were done in serial. With a bit of rearranging, and refactoring, all of these can be turned into this:
const [defaultBranch, currentBranch, dates, isMerged] = await Promise.all([
getDefaultBranch(git),
getCurrentBranch(git),
getAllBranchDates(git),
getAllMergedBranches(git),
])
The getAllMergedBranches(git) function still takes a very long time and I think it lists all remote branches that have been merged. Anyway, now it's only the slowest part of the Promise.all rather than one of multiple.

Comments
Nice win moving everything into Promise.all — that’s the obvious first big gain. At least now you’re paying the 500ms once instead of stacking multiple Git calls back to back.
If getAllMergedBranches is still the bottleneck, I’d look at narrowing scope. git branch --all --merged is expensive because it walks history and includes remotes. If you only care about branches merged into the default branch, try git branch --merged <default> and maybe drop --all unless you truly need remote refs.
Another option is caching. Merged status doesn’t change that often relative to local commands. Even a short-lived in-memory cache per run could help.
Half a second isn’t terrible, but for a CLI it’s noticeable. Reducing ref scope is probably your biggest lever now.
Mind blown! I didn't know about `git branch --merged <default>`. That's probably much faster. Going to experiment.
Actually, `git branch --all --merged <default>` lists all the remote branches too. So it's not any faster than `git branch --all --merged`.