DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Mathieu PATUREL
Mathieu PATUREL

Posted on

Programmatically get current git branch

Nice and easy. Works with git 1.6.3 and higher.

$ git rev-parse --abbrev-ref HEAD
master
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
rabbishuki profile image
Rabbi Shuki Gur

You can also use any of the following.

Windows: git branch | findstr \*
Linux: git branch | grep \*

🌚 Life is too short to browse without dark mode