Published on

How to get Current Working Branch in Git CLI

Authors

To get the current working branch without parsing anything we can just use the following git command

git branch --show-current # 👉 main (for example)

How does it work?

  • git branch is used to perform operations related to the branch like creating, deleting, listing, etc and running that alone will list down all the branches
  • By the --show-current option, we're filtering only the current working branch.

Happy fetching branch!