OS X (or Xcode) comes bundled with git 1.7.something, but after brew install git (1.8.0), which git keeps returning the old /usr/bin/git.

This is what I get when I echo $PATH right now:


Shouldn't Homebrew stuff take precedence?

Also, I've no idea where that usr/local/git/bin comes from at the end.

  • Have you verified that git is actually in /usr/local/bin?
    – Joe Bane
    Nov 3, 2012 at 1:45
  • yep. ls /usr/local/bin shows git is there. Brew also confirms that it's installed. I even ran the git uninstaller (both by brew uninstall and using the one that comes with the official git download) and redid brew install git. I keep getting which git = = /usr/bin/git".
    – o_o_o--
    Nov 3, 2012 at 2:00
  • 2
    Run which -a git to see if it's finding it at all.
    – Joe Bane
    Nov 3, 2012 at 2:04

3 Answers 3


Got it. The answer is in your question; brew installs git to /usr/local/git/bin (not /usr/local/bin) but since that's after /usr/bin in your path, you get that one first. My comment for which -a git should have pointed you in this direction.

  • 1
    Run ls -l /usr/local/bin/git too. I bet it is a symbolic link to /usr/bin/git.
    – Joe Bane
    Nov 3, 2012 at 2:10
  • Oh, and /usr/local/git/bin appears to be where the official installer puts it too.
    – Joe Bane
    Nov 3, 2012 at 2:13
  • You should look at /etc/paths and /etc/paths.d as well.
    – Joe Bane
    Nov 3, 2012 at 2:15
  • 1
    here's an interesting turn of events: which -a git returns /usr/local/bin/git; /usr/bin/git; /usr/local/bin/git. So I renamed the old git usr/bin/git_old and got it out of the way. Now git --version returns 1.8, proving that brew did install git successfully. -- Again, I renamed /usr/bin/git to its original name... and suddenly it's working properly! I don't know why or how, but renaming /usr/bin/git and running git once seems to have solved the problem. Who knows what the root of the problem was. Thanks anyway :)
    – o_o_o--
    Nov 3, 2012 at 2:18
  • That's ... odd. Glad you're up and running now at least.
    – Joe Bane
    Nov 3, 2012 at 2:25

I also encountered this issue.

After installing git through homebrew, if you run brew doctor then it will warn you that, as Joe mentioned above, the system is running the old git because its install location comes first.

But, in the same warning, homebrew gives the code to fix it:

$ echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

It’s been part of my Unix habits to have a ~/bin directory which I put at the start of my PATH. This is one of the first bits in my .bashrc:

case ":$PATH:" in
  *:$HOME/bin:*) ;;     # do nothing if $PATH already contains $HOME/bin
  *) PATH=$HOME/bin:$PATH ;;  # in every other case, add it to the front

With that in place, then selectively making just the Homebrew-managed git take precedence over the system version (instead of every Homebrew-managed binary), and just for your shell sessions (instead of all programs started from anywhere, including GUI programs), is as simple as symlinking it:

ln -s /usr/local/bin/git ~/bin/git

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.