loading...

Programmatically get current git branch

math2001 profile image Mathieu PATUREL ・1 min read

Nice and easy. Works with git 1.6.3 and higher.

$ git rev-parse --abbrev-ref HEAD
master

Discussion

pic
Editor guide
 

You can also use any of the following.

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