I created my own version for displaying the git branch in prompt starting from @vankasteelj reply (wrote on Mar 7, 2016).
It is a simple solution that includes branch status color. Take a look:
parse_git_bg() {
if [[ $(git status -s 2> /dev/null) ]]; then
echo -e "\033[0;31m"
else
echo -e "\033[0;32m"
fi
}
PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;34m\]@\[\033[0;34m\]\h \w\[$(parse_git_bg)\]$(__git_ps1)\n\[\033[0;32m\]\$\[\033[0m\]