Managing local git branches

April 17, 2020

cape-cod.JPG

Quick post alert!

Sometimes I end up working on multiple tasks at the same time. This usually means working with multiple branches at the same time or in the same sprint, etc.

To make it easier to switch context, I have this shell alias set up to give an overview of all local branches:

alias grecent="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) \
%(color:yellow)%(refname:short)%(color:reset) \
- %(contents:subject) \
- (%(color:green)%(committerdate:relative)%(color:reset))'"

And here is what the output looks like in my test repo:

Screen Shot 2020-04-17 at 4.22.22 PM.png

Note that the branches are sorted with most recently used one marked with an * and at the bottom.

Each branch shows timestamp last edited and the last commit message so it’s easier to switch context between tasks.

 
Previous
Previous

RecycleView Adapter with Click Listener

Next
Next

Git reset and friends