DEV Community

Programmatically get current git branch

Mathieu PATUREL on September 24, 2017

Nice and easy. Works with git 1.6.3 and higher. $ git rev-parse --abbrev-ref HEAD master Enter fullscreen mode Exit fullscreen...
Collapse
 
rabbishuki profile image
Rabbi Shuki Gur

You can also use any of the following.

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