Sunday, March 31, 2013

Display current Git branch in bash prompt

While working on a project I maintain multiple branches for development. I keep at least two branches, master (the default one) and develop. I work on develop branch and when I complete certain task I merge the work with master branch and push code to the repository. That's how I work :)

At times I forget on which branch I am working, I have to run:

git branch

to know the current branch. I am a bit lazy and I find running the same command again and again annoying. So I thought why not display the current branch in the command prompt. I did google search and found several results. This post is the result of those multiple search results.