/ WhatILearned

How to install git scm on your Mac OS X

On Mac OS X there is no apt-get command. apt-get is a Linux-Debian package manager, and it makes it easy to install, remove, update packages/programs/utilities on your Linux Machine.

I had to setup a MacBook Air with git and it seems like all the instructions tell you to go to git-scm.com and then follow the download instructions.

This didn't work for me because the installation package (also known as a DMG file) isn't authenticated and the system pops up an error dialog saying that it doesn't trust the software publisher.

It also doesn't give you an easy way around this warning.

The other recommended way is to install X-Code and it's command-line utilities. The problem being is that X-Code is nearly 4GB and will take a lot longer to install than just git. If you wanted to install the whole suite of coding tools you're usually prompted to do this whenever you type in git in the Terminal window and a popup asking if you want to install X-Code will show up. (I clicked Not Now.)

This leads us to using a package manager called Homebrew. Home-brew is a package manager for Mac OS X. Much like apt-get for Linux (I think it was inspired by). The default installation command is

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Which will install git on your Mac.

Note that your Mac will try to ask you if you want to install X-Code during the Homebrew process. This is not part of Homebrew, so when you see the popup do not click the option to install/get X-Code.

The homebrew installation process should take a few minutes (less than 5) and it should not take up a lot of space.

To check if you have git installed properly simply open up Terminal and then type in git --version this should echo a line saying git version 2.3.8 (or something to that effect.