a blog for those who code

Wednesday 25 June 2014

Get current branch name in Git

In this post we will be discussing about getting current branch name in Git. There are lot of ways in which you can get the name of your current branch as shown below .

git branch

This will show all the local branches of your repository. The starred branch is your current branch.
* branch_name

git rev-parse --abbrev-ref HEAD

This will display the name of current branch.

git symbolic-ref HEAD

This will display which branch head the given symbolic ref refers to and output its path.

git symbolic-ref --short HEAD

This will display the short branch name instead of full path.At last you can also use "git status" which will tell you whats your current branch.

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment