12

I downloaded and installed Git 1.8.4.2 from this link: http://git-scm.com/downloads. However, when I run git --version from the Terminal I get:

[~/workspace/ruby]:  git --version 
git version 1.7.4.4

I've tried restarting the terminal and my computer. I then tried using the info at https://code.google.com/p/git-osx-installer/wiki/Uninstall. I did the following in the terminal from within /usr:

sudo rm -rf /usr/local/git
sudo rm /etc/paths.d/git
sudo rm /etc/manpaths.d/git

I then ran the new git .dmg file again but am still getting 1.7.4.4 when I run git --version. I suppose there's something going on here with the Mac filesystem that I don't understand. Any help would be greatly appreciated!

sixty4bit
  • 7,422
  • 7
  • 33
  • 57

1 Answers1

17

Run the command:

which git

You'll probably see /usr/bin/git -- the Apple supplied version. This will be because /usr/bin appears in your PATH environment variable before /usr/local/git/bin. You can verify this by running the command:

echo $PATH

If that is the case then run this command:

export PATH=/usr/local/git/bin:$PATH

and then try git --version again. You should now get 1.8.4.2. This hasn't fixed it permanently yet though. You'll need to add the export PATH=... line to your ~/.bashrc so that it gets set for every shell.

sjs
  • 8,830
  • 3
  • 19
  • 19
  • Thank you! Worked like a charm. I was able to see it had something to do with $PATH from other questions here but I couldn't find the right line to add to my ~/.bashrc (I ran open ~/.bash_profile which is the same thing, right?). THanks again! – sixty4bit Dec 11 '13 at 00:55
  • 1
    @sixty4bit See [here](http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment) for an explanation of the difference between `~/.bashrc` and `~/.bash_profile`. – sjs Dec 11 '13 at 01:03