I just upgraded to OS X Lion and now cannot initialize Git where it used to work fine:

$ git add .

-bash: git: command not found

I'm new to Git and to programming, so I'm sure it's a quick fix, any help is greatly appreciated. Thanks guys!

  • 1
    do you have macports installed?
    – jamapag
    Commented Jul 20, 2011 at 16:57
  • i do not...do you recommend installing?
    – pruett
    Commented Jul 20, 2011 at 16:58
  • 9
    personally I would install it using homebrew instead of macports - mxcl.github.com/homebrew
    – house9
    Commented Jul 20, 2011 at 17:56
  • 2
    brew > ports, also maybe git just isn't in your $PATH any longer. Try sudo find / -name git and you might just find your binary.
    – Nick Radford
    Commented Jul 20, 2011 at 18:05
  • 1
    Why would you recommend Macports or Homebrew just for git? Just curious. I've been using code.google.com/p/git-osx-installer Commented Apr 24, 2012 at 22:45

16 Answers 16


Lion (and Snow Leopard) didn't ship with git - so perhaps the way you installed git didn't survive the upgrade. You'll need to find your copy of git or just get a new copy. Using spotlight to search your Time Machine backups might be fruitful to find the files and know if it's a path issue or the binaries are truly gone after Lion migrated your data.

All of your repos stored in user space are fine. Do try to get the same or newer version of git.

The command line mdfind -name git will list all files that spotlight has seen with git in the name. Most installations of git should survive an upgrade to Lion and you only have to clean up your environment or link to the binary from somewhere in your $PATH.

Xcode 4(4.0-4.2) drops git into /Developer/usr/bin along with most of the other tools you need like make and gcc. It might be simplest to maintain git after getting the (currently) free Xcode from the App Store. Xcode 4.3 puts giy and other tools in Applications/Xcode.app/Contents/Developer/usr/bin.

To avoid issues with different versions, you might want to make sure any old versions are gone from your hard drive. (and certainly from your $PATH)

  • AWESOME! I posted this question while downloading the new Xcode. Just checked now and it works! Thanks @Johan Nordberg
    – pruett
    Commented Jul 21, 2011 at 14:26
  • 3
    Note XCode for Lion just installs the installer. You'll need to visits your apps folder and run a install app to have git.
    – nailer
    Commented Jul 21, 2011 at 16:27
  • 2
    I have Git in /usr/bin/git. I installed Xcode 4 on a clean (reformat) install of Lion and I don’t remember ever running the Git installer.
    – Nate
    Commented Aug 1, 2011 at 16:57
  • 1
    I have Lion (10.7.3) and just installed XCode via the App store. It's in the Applications directory and not Developer. In fact I don't even have a /Developer directory.
    – milesmeow
    Commented Feb 18, 2012 at 16:30
  • 8
    Xcode -> Preferences -> Downloads -> Install Command Line Tools. See my answer below.
    – elsurudo
    Commented Apr 11, 2012 at 15:05

If /usr/local/git already exists, you'll need to either add it to your $PATH or make a symlink placing the symlink inside a directory that is in your existing PATH.

A common practice is to make /usr/local/bin if it doesn't exist and add a link:

sudo -s
mkdir -p /usr/local/bin
ln -s /usr/local/git/bin/git /usr/local/bin/git
  • 4
    this is the proper answer
    – TheLindyHop
    Commented Jul 21, 2011 at 17:10
  • /usr/local/git exist but I get: "ln: /usr/local/bin/git: No such file or directory."
    – Kevin Tsoi
    Commented Jul 21, 2011 at 21:41
  • This is what we needed I guess. It does what it should do. Thanks!
    – Ren-D
    Commented Jul 22, 2011 at 8:02
  • 1
    This is exactly what fixes the problem; this should have been marked as the correct answer Commented Jul 30, 2011 at 4:32
  • 1
    Even though the majority of people will have git installed in /usr/local/git perhaps the OP appreciated thhe general answer. Anyone who wants to re-ask this question stating the chosen answer here didn't work could then select this answer when it gets provided. No harm in two valid questions with two valid answers.
    – bmike
    Commented Sep 11, 2011 at 20:40

If you have XCode installed, the best solution is Xcode -> Preferences -> Downloads -> Install Command Line Tools.

This put git (among other things) at /usr/bin/git.

If you don't have Xcode installed, then installing it just for git would definitely be overkill.

  • 1
    Thanks for this - definitely the easiest way to go if you already have XCode installed. Commented Jul 3, 2012 at 2:16

I think you will find that Git is still installed on your system. It looks like the PATH is just messed up. Check to see if /usr/local/git still exists on your system.

I just added the following to my ~/.bashrc file and everything is back to normal.


To be more specific, this site - http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html - details the difference between .bashrc and .bash_profile. If you use Mac's terminal with Git, then adding the above PATH specification to your .bash_profile will do the job. Of course, you'll have to close the Terminal window and open a new one because the .bash_profile file is loaded on a Terminal window's opening.

In summary, adding this to .bash_profile would work too.

  • That's exactly what I did too and git is working again.
    – Kleber S.
    Commented Jul 22, 2011 at 5:17
  • 2
    This is the correct solution. It's only the PATH that is messed up. The other answers people have given here are workarounds, rather than the solution.
    – Dan Smart
    Commented Jul 22, 2011 at 8:28
  • I tried doing this, but still get a command not found error when trying git add. Do I need to completely restart my computer to get the path to update?
    – EmmyS
    Commented May 9, 2012 at 16:26
  • Did you restart your terminal? Or source your .bash_profile file? Just type source .bash_profile in your terminal while in your home dir Commented May 10, 2012 at 14:08
  • yes, I restarted my terminal. I'm not sure what source means, but the answer by ing0 below (minus the reinstall of git) worked for me. Possibly my bashrc file was in the wrong place. In any case, it's working now.
    – EmmyS
    Commented May 10, 2012 at 16:37

Step 1: Reinstall git (I just installed the Snow Leopard version from here) if it's not in:


Step 2: Open Terminal and do the following:

cd /etc

sudo nano bashrc

Then in nano at the top of the file write (as aaron suggested)


Press Ctrl+X to quit nano and press Y to save. Then exit terminal and reopen and git should be working for you.

  • You shouldn't need to reinstall Git. I believe you will find it is still installed. Check /usr/local/git
    – Aaron Chambers
    Commented Jul 21, 2011 at 10:52
  • Mine had gone completely. So I reinstalled. Like I said, if it's there then there's no need to do it!
    – ingh.am
    Commented Jul 21, 2011 at 11:23
  • This worked for me as well. Everything worked fine before the Lion upgrade--this was a quicker solution than downloading the 4+ GB XCode.
    – jnunn
    Commented Jul 21, 2011 at 15:03

Possibly, you had installed git through MacPorts or Fink.

I think it will take some time to have a release of either for Lion... or possibly you should try and reinstall it...

Indeed, it seems that you need to install MacPorts from trunk to get Lion compatibility...

Fink has also got some hints about upgrading to Lion.

  • I had macports installed and working before my Lion upgrade. My port command still works fine (ex: port selfupdate) but now my installed ports (ex: git) do not. I can see the packages are still in /opt/local/var. I thought it may be a $PATH issue, but ~/.profile still has my previous (before upgrade) macports configurations. Any suggestions?
    – Adam Tootle
    Commented Jul 20, 2011 at 19:57
  • @Adam Tootle: See the "install MacPorts from trunk" bit in my answer...
    – sergio
    Commented Jul 20, 2011 at 20:03
  • I wasn't sure if I needed that or not since it was working ;) If I do that I shouldn't have to reinstall all of my packages should I?
    – Adam Tootle
    Commented Jul 20, 2011 at 20:06
  • @Adam Tootle: I do think so... the point is that with Lion all system frameworks and libraries have changed (as usual with a major release)...
    – sergio
    Commented Jul 20, 2011 at 20:16
  • ahh..gotcha. well there goes any productivity for the afternoon haha
    – Adam Tootle
    Commented Jul 20, 2011 at 20:21

From StackOverflow:

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

then run source ~/.bash_profile in Terminal

Link to the post there: https://stackoverflow.com/questions/6810059/git-on-mac-os-x-lion/6810082#6810082


If you are using brew, just run this command from the terminal.

brew install git


This happened because git stop being part of the $PATH (for some migration reason).

There is a very simple way of fixing this in OS X:

In OS X, you can add variables to $PATH by changing the file


so, you can put back git doing the following:

sudo vim /etc/paths

add /usr/local/git/bin to the end of the file, save, and exit. Restart shell. Git should work.

  • 1
    /etc, are you sure? Shouldn't this rather be /usr?
    – nohillside
    Commented Aug 28, 2013 at 15:36

Just download the newest version from here: http://code.google.com/p/git-osx-installer/

Install it, open up a new terminal, and it works like before :D


Same issue here, downloaded and installed the snow leopard version from google code and off I went. Needed to quit and re-open terminal though...

All is well again..


When there is git path already,

just add directory to your PATH variable.

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


I used the App Store to install Xcode and it just gives you an all in one app blob. However it DOES have other apps and installers in it. I just needed git so the path from that is export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin

Its a bit of a hack, but I don't use Xcode for a lot of stuff. Add to your bash config as other posters described and your good to go

  • Instead of messing with $PATH it's actually easier to install the Command Line Utilities from within Xcode and use /usr/bin/git afterwards
    – nohillside
    Commented Nov 5, 2012 at 15:44

I fixed it by downloading and reinstalling git from here.


You don't need to modify the path or install the Xcode command-line tools. Just use the "xcrun" utility from the Terminal: http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/

  • Welcome to Ask Different! It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone. Please take a look at the FAQs for more info.
    – gentmatt
    Commented Sep 27, 2012 at 9:00

I solved it by following advice on this site:


It was just a pathing issue. To be honest, I expected a whole lot more issues. The upgrades are getting smoother. I remember when I upgraded from Tiger to Leopard, just about everything "open source" broke..

You must log in to answer this question.