Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
$ which 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?

share|improve this question
git is installed by Xcode. I can't tell you if it'll break anything, though. In your shoes, I'd rename it in case I need to put it back later. – Steven Fisher Feb 3 '12 at 0:45
ah ok..Well what I'll do is just rename the new installt o git2 or something and use it like that. – cromestant Feb 3 '12 at 0:52
I meant rename the old one, rather than removing it. That way if you DO have problems you can just rename it back. – Steven Fisher Feb 3 '12 at 1:10
@StevenFisher you should make that an answer. :) – Ian C. Feb 3 '12 at 2:04
OK. I was hoping someone would have a real answer that didn't have an "I don't know!" in it. :) – Steven Fisher Feb 3 '12 at 2:32
up vote 23 down vote accepted

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.

share|improve this answer
3 alternatives: confirming that the first one worked well. – Marius Butuc Jul 16 '12 at 18:28

You don't need to go hacking the other version out unless you are really tight for space. Edit your .bash_profile and make sure that /usr/local/bin occurs in front of /usr/bin in your PATH variable

Personally I prefer to adopt a scheme with tool paths defined and the path built from these e.g.


PATH=${GIT_HOME}/bin:${PATH};export PATH

This means that anything that searches for tools using the PATH will find your version of git, and anything that "really must" have the /usr/bin version will most likely have that path hard wired in and can still find it

share|improve this answer

I had the same problem: an old version of Git that was the Xcode version. I've tried to install a new version of Git from and updated the bash_profile with


Then reload your bash and try git --version

Worked for me :)

share|improve this answer

On my system (10.7.3, Xcode 4.3.2) Xcode's git is not installed in /usr/bin/git. All of Xcode 4 (like all apps from the App Store, I think) is in its .app bundle. Specifically, its git is at /Applications/

I use git (via Xcode) all the time, and I have no /usr/bin/git here at all. So it's not part of the default Lion install, either, or at least, not at that location.

FWIW, the git in the bundle has a --version that reads:

git version (Apple Git-26)

so I bet your /usr/bin/git is your own installation, and updating it can't hurt anything.

Alternatively, you could install Xcode (it's free!), and put /Applications/ in your $PATH, but that's overkill if you only want git.

share|improve this answer
I also have xcode, so I have three versions of git currently installed... nice find! – cromestant May 15 '12 at 14:08
if you don't have /usr/bin/git, you probably didn't install the Xcode "Command Line Tools". see – Justin M. Keyes Dec 9 '12 at 16:06

Ken is correct in that git was only available through the path. When I installed Mountain Lion (10.8), suddenly I had git in /usr/bin/git, so it was a Mountain Lion addition as far as I can tell...

Although...I have installed quite a few things since and am not entirely sure it wasn't a dependency for something else.

share|improve this answer

I really don't know, I think I haven't installed git or XCode for the momment but after install homebrew and run brew doctor it says:

$ brew doctor
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:


Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH="/usr/local/bin:$PATH" >> ~/.bash_profile

So why? I just installed Command Line Tools for XCode (mountain Lion) and I think this one is the one who installed it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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