If you type "git --version" in your terminal and see a message like "git version 2.0.1", you have an official version installed, but may need to update it to utilize the latest release. I'll show you how to do that in this video.
- Check the Git download site and click the "Downloads for Mac" link to see what the latest release is. In my case it says "You are downloading version 2.2.1"
- If it's the version that your system indicates is installed, you can stop watching this video and start using Git now!
- If it's a newer version number than the one your system is reporting, then you should download the latest version of Git for Mac and continue following this video.
- Open the Disk image
Before we begin the installation process, I'll open up the README.txt file that comes with the disk image. I'll walk you through these steps now, but it's a good idea for you to open this up and read through it yourself in case there's an update in the future.
Uninstalling the current version of Git
According to the README.txt file, to upgrade your version of Git, you should first uninstall the old version using the uninstall.sh script included in the download. I'll do that now.
- I'll simply drag the "uninstall.sh" file from the disk image onto my terminal window. (This loads the path to the script in the terminal.)
- Then, switch to the terminal and press Enter
- When asked if I'm sure I want to uninstall, I'll type "yes" and press Enter
- Then, enter my password and press Enter one last time
Now, the old version of git is uninstalled and we can verify it by typing "ls /usr/local". Since it's uninstalled, we don't see it in the list here.
Now we can install the version that we just downloaded.
Installing the latest release of Git
- Double click the ".pkg" installer file
- If presented a pop up saying that cannot be installed because it is from an unidentified developer, you can override this security feature for this application only.
* Click OK
* Right-click (or hold the control key and click) on the ".pkg" file and select "Open"
* Now, select Open
- Click "Continue" to begin the installation process
- Then, click install
- You may be asked for your administrator password. Type it in and click "Install Software".
- Once the installation is complete, click "Close".
- The next step in the README.txt file is to restart bash sessions. I'll simply quit iTerm, and re-open it. If you have any terminal windows, GNU Screens or TMUX sessions open, you'll need to restart those, or run "source /etc/profile" in each of them.
The final step is optional, and allows non-terminal applications to see Git. There's no harm in running it, and you may find it useful in the future, so I'm going to go ahead and run the script.
- Switch back to Finder, and drag the "setup git PATH for non-terminal programs.sh" file into your terminal window. (This loads the path to the script in the terminal.)
- Press Enter
- Finally, you need to logout of your Mac OSX user account and log back in. (A restart would also work.)
Now, when I open up iTerm type "git --version", we see the message "git version 2.2.1". So, we're ready to go!