Programmatically get current git branch
Mathieu PATUREL

Mathieu PATUREL @math2001

About: Don't have much inspiration for an original bio right now...

Location:
Australia
Joined:
Apr 23, 2017

Programmatically get current git branch

Publish Date: Sep 24 '17
8 1

Nice and easy. Works with git 1.6.3 and higher.

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

Comments 1 total

  • Rabbi Shuki Gur
    Rabbi Shuki GurFeb 13, 2019

    You can also use any of the following.

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

Add comment