Git Is Gone In OS X Mountain Lion

gitThis blog post is for a very specific group of people who cared enough to notice that git command line tool is not working on their brand new MacBooks with Mountain Lion! If that sentence didn’t make sense to you, then you are probably at the wrong place. I got my new Mac last week and I wanted to clone some code from Github. So I opened the terminal to clone it and behold, “git” is apparently not a recognized command! I have already installed the latest developer preview of Xcode (version 4.6 DP3), so what went wrong here? It turns out that we need to manually install the git command line tools. We still live in a world where git is not an integral part of all the systems! Xcode 4.6 doesn’t install the command line tools by default, and Git is one of the tools included in these command line tools. Anyway, there’s a simple fix for it.  

Using Macports

If you are still reading this, then I assume you would have already tried this method. But just for the sake of completeness, I will describe it. If you don’t have Macports installed, you can install it from here. Once you install it, open the terminal and type the following:

$ sudo port install git-core +svn +doc +bash_completion +gitweb

That should install git for you. Make sure your PATH environment variable contains the path to git. Follow these steps:

  • Open your ~/.bash_profile using the following command:
     $ sudo vi ~/.bash_profile
  • Add this line to the “bash_profile” file:
     export PATH=$PATH:/usr/local/git/bin/
  • Save and close the file. Then type the following on the terminal to make sure the changes take place:
     $ source ~/.bash_profile

Open the terminal and try to git clone something. If that doesn’t work, then read on, there’s another method!

Using Xcode

If you are reading this section, then the above method probably didn’t work for you. You may also have tried a couple of other methods as well. If nothing has worked for you yet, the following steps definitely will. Make sure you have Xcode installed, and then do the following:

  • Open Xcode
  • Select Xcode -> Preferences
  • A new window will pop up. Select “Downloads” tab on the top
  • You should see “Command Line Tools” listed there. Click on “Install” located on that line.
  • Go back and check on your terminal. Git should now be up and running!


One thought on “Git Is Gone In OS X Mountain Lion

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s