Homebrew installation of git won't take precedence over system version (in /usr/bin/)
Solution 1
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.
Solution 2
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
o_o_o--
Updated on September 18, 2022Comments
-
o_o_o-- over 1 year
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:
/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
Shouldn't Homebrew stuff take precedence?
Also, I've no idea where that
usr/local/git/bin
comes from at the end.-
Admin over 11 yearsHave you verified that git is actually in /usr/local/bin?
-
Admin over 11 yearsyep.
ls /usr/local/bin
showsgit
is there. Brew also confirms that it's installed. I even ran the git uninstaller (both bybrew uninstall
and using the one that comes with the official git download) and redidbrew install git
. I keep gettingwhich git = = /usr/bin/git"
.
-
-
Joe Bane over 11 yearsRun
ls -l /usr/local/bin/git
too. I bet it is a symbolic link to/usr/bin/git
. -
Joe Bane over 11 yearsOh, and
/usr/local/git/bin
appears to be where the official installer puts it too. -
Joe Bane over 11 yearsYou should look at
/etc/paths
and/etc/paths.d
as well. -
o_o_o-- over 11 yearshere'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 gitusr/bin/git_old
and got it out of the way. Nowgit --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 :) -
Joe Bane over 11 yearsThat's ... odd. Glad you're up and running now at least.