How do I get the name of the current branch in Git?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
should show all the local branches of your repo. The starred branch is your current branch.
To retrieve only the name of the branch you are on:
Version 2.22 adds the
--show-currentoption to ”print the name of the current branch”. The combination also works for freshly initialized repositories before the first commit: