DEV Community

Ravi Ojha
Ravi Ojha

Posted on

3 1

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

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

Top comments (1)

Collapse
 
shayd16 profile image
Shayne Darren

You could also do a

git checkout -

to switch to your most recently used branch

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay