Denis Barushev

Email: barushev@gmail.com

-bash: __git_ps1: command not found

If you use homebrew and have updated your git to 1.7.12 you should see this annoying message instead of your beautiful prompt:

-bash: __git_ps1: command not found

To solve the problem just add this line to your ~/.profile ( ~/.bash_profile, ~/.bashrc) before setting PS1:

source /usr/local/share/git-core/contrib/completion/git-prompt.sh

Update: The issue was fixed in the latest version of the git homebrew formula:

brew update
brew uninstall git
brew install git

Adding Bash Completion for Git on Mac OS X Snow Leopard

Copy this code and paste it into Terminal.

This also should work for any *NIX.

Update

There are the easiest ways to add bash completion for git.

For Mac OS X

Install git via MacPorts:

sudo port install git-core +bash_completion

Then add the following lines at the end of your ~/.profile:

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

For Ubuntu

sudo aptitude install git-completion

For Fedora

sudo smart install bash-completion

Using Kompare for Git Diffs

git-kompare

It’s possible to use kompare as a graphical diff viewer for git. I created file git-kompare in my /usr/local/bin/ directory with such content:

git diff $* | kompare -

I also created alias gk for this command in my ~.bashrc:

alias gk='git-kompare'

Now I can use gk command instead of git diff with all its options.

Update from Sean Blanton:

You can shorten this with a bash function:

gk () { git diff $* | kompare - ; }

Bash functions can handle the pipes and arguments better than aliases.

Removing a Remote git Branch

git push origin :branch_name