MacOS – Where did /usr/bin/git come from

gitmacos

I have a small problem. At some point I used git but I don't remember if it was installed by default on Lion.

Here is the version and path of git:

$ git --version
git version 1.7.5.4
$ which git
/usr/bin/git

I also have a newer git in /usr/local/git

I would like to use the newer version but I don't know if by removing the old one (/usr/bin has precedence in the path variable) I'll break something.

What is the proper way to resolve this conflict?

Best Answer

git is installed by Xcode. I doubt you'll have any problems if you replace it, but I can't give you a definitive answer to that…

  1. What I'd do is rename the old /usr/bin/git to git_old, then rely on your path to select the new one.
  2. If that doesn't work, move the new one to /usr/bin. I doubt Xcode is picky about which version of git it's using.
  3. If that still doesn't work, move git_old back to /usr/bin/git and use either a direct path, rename, or alias for your new one.

I doubt you'll have to go past #1 above, though. That should be enough.

Edit: I read your original post backwards. The first thing you should do is make sure your path includes the new git directory BEFORE the directory that contains the old git.