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:


About the author: My name is Miikka Koskinen. I'm an experienced software engineer and consultant focused on solving problems in storing data in cloud: ingesting the data, storing it efficiently, scaling the processing, and optimizing the costs.

Could you use help with that? Get in touch at miikka@jacksnipe.fi.

Want to get these articles to your inbox? Subscribe to the newsletter: