- Ashik Nesin
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 branchis 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-currentoption, we're filtering only the current working branch.
Happy fetching branch!