loading...

How to get the current git branch name?

barisic profile image Ante Barišić ・1 min read

An easy way of doing it:

git branch | grep \*

Discussion

pic
Editor guide
Collapse
deciduously profile image
Ben Lovy

You can also use __git_ps1:

$ __git_ps1
 (master)
Collapse
fennecdjay profile image
Jérémie Astor

This is not working on my machine (running ArchLinux), where is this command from?

Collapse
deciduously profile image
Ben Lovy

Hm, I don't remember. It's worked for me on both Gentoo and Debian/Ubuntu (and derivatives), but don't know much about Arch. It's been in my ~/.bashrc for years, I don't know where I got it or why it wouldn't work on Arch.