I didn’t know until yesterday about the __git_ps1 command. You can include it in your bash PS1 like this:
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
and whenever you’re in a git directory, it will include the current branch in your prompt, along with a few other goodies.
I did this and it didn’t work. It just displayed __git_ps1 in my prompt all the time, which is ugly and not terribly useful.
I couldn’t find an answer on Google, so I ended up just disabling lines in my .bashrc until I could figure out what was wrong. I ended up having to disable this line:
shopt -u promptvars
I don’t know why it was on; perhaps I had a reason for it once and then copied the bashrc from computer to computer, but it’s gone now and my git bash prompt works.
So if you’ve recently heard about __git_ps1 and it’s not working for you, look for the promptvars shopt.