Install Git on macOS Mojave and earlier, and Update to latest version

git
macos
#1

This topic will help you to Install Git on macOS Mojave and earlier, and Update to latest version properly.

First off, In order to operate the installation of Git on macOS Mojave, Sierra, or an older Mac OSX version, downloading the latest GIT version from the Git home page or from the direct macOS latest link.

Installation of GIT on macOS

  • Step 1: Open the dmg file, then Control/Right Click the git.pkg file to install.

  • Step 2: When Git is installed check in the Terminal, launch the Terminal from /Applications/Utilities and check the version:

git --version

And the version is displayed

git version 2.19.0

To see where it is located

which git

And the location is shown

/usr/local/git/bin/git

Upgrading Git from a previous version to the latest

If your device is already installed GIT, you should remove it by using the uninstall.sh script… to prepare your Mac for the update of the latest version.

/usr/local/git/uninstall.sh

Then, operate the same process of downloading and mounting the latest git .dmg …

Your recent Git configuration settings and working storage will not be changed.

Trumping Xcodes Older Git

If Xcode and command line tools had been already installed on your device before you installed Git, it is possible that the older version is distributed with Xcode, the default path for the installation is:

/usr/bin/git

The Mojave version is:

git version 2.17.1 (Apple Git-112)

In order to launch the latest version you need to modify your shell path so that /usr/bin/git runs after /usr/local/bin

It is necessary to customize shell path , the path will be set in either .bashrc or .bash_profile in your home directory, more likely .bash_profile

Then, you can add into the path the same as the tet below and keep what you recently have in the path, each section is separated by a colon:

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

Finally, Restart or reload the Terminal and now you will have the up-to-date Git version.

0 Likes