How to get the current branch name in git
I have some branches in my Git repository. I want to check the current branch name. How can I check that?
You can run the git branch command in your CMD.
$ git branch
It should show all the local branches of your repo. The starred branch is your current branch.
Or, there are several ways to get current branch name in Git:
git-branch.
We can use the --show-current option of the git-branch command to print the current branch's name.
git-rev-parse.
Another plausible way of retrieving the name of the current branch is with git-rev-parse.
git-symbolic-ref.
git-name-rev.