How do I modify cygwin's PS1 for git bash completion?

Here is my current PS1:

$ echo $PS1
\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$

I have installed git bash completion and it isn’t showing the current branch in my command prompt. I think this needs to be edited but I’ve got no idea what to change to make it show the current branch. Note that I like the colors and general structure (i.e. with $ on its own line), so I’d like to keep that if possible.

  • Git clone with username password authentication in one go
  • Can't store sh command output through DSL (groovy) in Jenkins pipeline job
  • Git Bash won't run my python files?
  • git stderr output can't pipe
  • Truly Portable Git
  • “${1-}” vs “$1”
  • DVCS how structure with large integrated code base, with multiple projects sharing much common code?
  • How do I build and use the latest version of git on cygwin?
  • How to Change the Default Editor for Git
  • Recursively add the entire folder to a repository
  • Why am I getting an empty repo when cloning my keystone app to local repo from heroku?
  • Putting output of 'git describe' in template using play framework?
  • One Solution collect form web for “How do I modify cygwin's PS1 for git bash completion?”

    Modify the prompt string and add $(__git_ps1 " (%s)") somewhere.

    For example, try typing this into Bash:

    export PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]$(__git_ps1 ' (%s)')\n\$"
    

    Once you find something you like, add that line to one of Bash’s startup files, e.g. $HOME/.bashrc.

    The source for git-prompt.sh is well-commented and worth browsing if you’re curious about other options.

    Note that you may have to manually source path/to/git-prompt.sh before this will work. If so, add this line to your config file as well, above the export PS1 bit.

    Git Baby is a git and github fan, let's start git clone.