Using GitBash with Git for Windows, my PS1 variable is set to display current branch as such:
$ echo $PS1
\[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$
This works fine to start, for example my prompt starts out like
myuser@mypc MINGW64 /c/git/myrepo (master)
$
However, after I run any git command, the current branch portion is omitted until I restart the shell.
myuser@mypc MINGW64 /c/git/myrepo (master)
$ git branch
* master
myOtherBranch
myuser@mypc MINGW64 /c/git/myrepo
$
But if I run __git_ps1 it still tells me the correct value:
myuser@mypc MINGW64 /c/git/myrepo
$ echo `__git_ps1`
(master)
myuser@mypc MINGW64 /c/git/myrepo
$
Any ideas what could be happening, or how I could go about diagnosing/fixing this issue?
PS1value and don't observe this behavior. After you run a git command but before restarting the shell (i.e. while it is not showing the branch name), have you verified that thePS1value is still as you expect? (It shouldn't change, but perhaps an alias is set up that's doing something it shouldn't; is there someone that might have had access to your profile, that might be playing a little joke?)