Forgot the name of your recently used git branch? Gotcha fam!

twitter logo ・1 min read

Add this alias to your terminal's rc or profile file. For most users, it is .bashrc or .bash_profile in the home directory. Fire up a new terminal tab, cd to any git repository and try out the command gitrecent.

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

Source: This stackoverflow answer

twitter logo DISCUSS (1)
markdown guide
 

You could also do a

git checkout -

to switch to your most recently used branch

Classic DEV Post from May 10

Why I ignore the hype (and you should too)

It’s been 20 years since I made my first website. I've been burned by the hype ti...

Ravi Ojha profile image
Full-stack Software Engineer by passion. A product person. On lazy weekends, I either indulge into graphic design or write blog posts on rookieslab.com.