https://stackoverflow.com/questions/8957862/how-to-upgrade-git-to-latest-version-on-macos#8963503
It's simple if you already have Homebrew: Assuming you have homebrew installed, type the following:
brew install git
Once it is installed, then type the following two lines, which will set our path to the local git distro instead of the Apple one.
export PATH=/usr/local/bin:$PATH
git --version
IF YOU DON'T HAVE HOMEBREW, FOLLOW THESE STEPS Check version
$ git --version
Backup (or remove) Apple git (Optional)
$ sudo mv /usr/bin/git /usr/bin/git-apple
Install Homebrew if you didn’t have
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Or update if you already have
$ brew update && brew upgrade
Install Git with Homebrew
$ brew install git
Symbolic link
$ brew link --force git
Close Terminal and reopen then check version
$ git --version
You should see…
git version <latest version>
Nice! We’re safe now! And next time you can just…
$ brew update && brew upgrade