• 0

How to get the name of your current git branch

So you want to get the name of the git branch that you are on. There are 2 main ways to find that out depending upon what you want to do after you know your current branch name.

1) List all of your branches. The one that is marked with an asterisk is your current branch

git branch

2) Only get the branch name. Useful if you need to get this as an argument or variable in a script.

git rev-parse --abbrev-ref HEAD

While we are at it, lets also get the commit checksum of the HEAD.

git rev-parse --verify HEAD