Quickly jumping between git branches

When working on software with Git, I create a new branch for every change request I’m going to make. This means that I might be working on a bunch of branches in any repository. How to switch between them easily?

I use a small script to do it, called git-b (the name is inspired by autojump’s j). It gives you list of branches ordered by the time of the latest commit. It uses selecta so you get to choose the branch by typing a part of its name. It’s simple, but so much better than git checkout <tab>, which is what I did before. (I imagine you could actually configure zsh’s tab completion for similar experience. Alas.)

Here’s the code:

Comments or questions? Tweet to me or send me an e-mail.