Never miss a branch again

When working with a git repository you need to know which branch you are committing to. To do that you type git status and check for the info. Sometimes you just need to know the branch in order not to make mistakes when merging. It is super useful to have branch name as part of the command prompt.

Jim Myhrberg created a repository on GitHub with code and instructions on how to achieve this:

Instructions for installation are pretty simple and work quite well out of the box.

There are a lot of forks of this repository. Specially interesting is this one by Paul “Joey” Clark: 

  • shows you how far your local branch is ahead or behind the repository’s branch
  • shows how many files are staged
  • indicates when you have an un-popped stash (when the top stash entry was made on the current commit or the current branch)
  • displays when you are on a detached commit, or paused during a merge, rebase or cherry-pick
  • adds a timeout for slower machines so that you will get your prompt quickly, even if git status is taking too long to retrieve the dirty and staged stats.

In the end, you are left with branch name in your prompt:

Or, like this if you used joeytwiddle’s repository:


By Aleksandar Jakovljević

My name is Aleksandar Jakovljević and I am a web developer from Belgrade, Serbia. I was born in Smederevo, in 1980. I started focusing on web development since late 2003. I am mostly focused on open source web technologies. I specialised in PHP, focusing on Symfony framework, with skills in Drupal and WordPress, too. I worked more than 7 years for art_net studio and 10 years for Computer Rock (former Spoiled Milk). Now I am working on developing industry leading subscription management system as a part of Plenigo team since August 2021. I love the web and everything related to it. The possibility to publish your ideas quickly and make them available to the entire world is what made me decide to pursue a career in web development.

Follow on: Twitter | GitHub | LinkedIn | Facebook | Instagram

Hire me on Upwork

Leave a comment

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.