DEV Community 👩‍💻👨‍💻

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 \*

Create an Organization Does your company have something to share with DEV?

Create an Organization and start sharing content with the community on DEV.