configuring git completion on mac osx

  1. PS1=’[\u@\h \w$(__git_ps1 ” (%s)”)]\$ ‘PS1=’[\u@\h \w$(__git_ps1 ” (%s)”)]\$ ‘PS1=’[\u@\h \w$(__git_ps1 ” (%s)”)]\$download/checkout git-completion.bash git-prompt.sh from https://github.com/git/git/tree/master/contrib/completion to ur favourite directory 
    1. I downloaded mine to ~/bin
  2. include them in .bashrc/.bash_profile
    1. I added the following line in .bash_profile 

      source ~/bin/git-completion.bash
      source ~/bin/git-prompt.sh

    2. opt: you could also do a file exists check before doing the include
  3. change you prompt to include __git_ps1 variable
    1. for ex: after the above source lines do PS1=’[\u@\h \w$(__git_ps1 ” (%s)”)]\$
  4. after you restart the terminal/run bashrc again, you will see the branch information when you are at a git directory.you will also be able to tab-complete git commands

optionally you can color your prompt by following the instructions at