Get current branch name in Git

 Sometime there may be cases when we need to know the current branch we are working with. There are a number of ways to get the name of the current branch.

Most cronical way to displays the full refspec:

git symbolic-ref HEAD

To show only the branch name (Git v1.8 and later):

git symbolic-ref --short HEAD

On Git v1.7+ you can also use the following command:

git rev-parse --abbrev-ref HEAD

or with Git 2.22 and above:

git branch --show-current



Post a Comment

If you have any questions or concerns, please let me know.

Previous Post Next Post