How to do upgrade Git in Mac OS X?

upgrade git in mac os xGit SCM does not comes out-of-the-box(OOTB) with Mac OS X.  However if you have installed Xcode  command line tools or standalone Git Installer then you will have Git SCM on Mac OS X.


Warm Up!

Let’s check existing Git version on your machine.

Scenario 1: You will get similar to this version!

OR

Scenario 2: you may get like this

If you get below message nothing to worry; it means you have not yet installed Git SCM on your machine


Let’s start Git upgrade

First thing, get the latest Git SCM for Mac OS X Click here to Download(from git-scm.com).  You will get .dmg file.  In this article I’m using current latest version of Git SCM 1.7.11.3 for upgrade!

  • Open the downloaded git-x.x.x.x-intel-universal-snow-leopard.dmg
  • You will see uninstall.sh, Run this shell script (if you have scenario 2 on your machine, skip this step)
  • Run the git-x.x.x.x-intel-universal-snow-leopard.pkg installer and follow the installer instruction
    • This installs the Git in /usr/local/git (root access is required)

Once you finished the package execution (after, click of ‘Finish‘ button)


Git Upgrade Verification

Restart your bash session.  If you wish to preserve your precious screen session, just execute source /etc/profile.  Verifying Git version

Wow, you successfully completed upgrade Git in Mac OS X 🙂

How to handle if I still getting Git old version displayed on my Terminal.  I know it may happen, don’t worry I will explain.  Follow below instructions.

Adding PATH variable to .bash_profile; open up Terminal.app

Place the below export statement at the end of .bash_profile

Save your modified .bash_profile and close the vim editor.  Either close and re-open your Terminal or execute below command

Now verify Git version and you’re good to go 🙂


Git for Non-terminal programs (Optional Step/Instruction for you)

Typically Non-terminal programs don’t inherit the system wide PATH and  MANPATH variables that your terminal does.  If you’d like them to be able to see latest Git for any reason.

Run this shell ‘setup git PATH for non-terminal programs.sh’ from the downloaded .dmg installer

Above script will add the PATH and MANPATH to your ~/.MacOSX/environment.plist file.

You’ll need to log out of your user account for that to take effect.