To start off, you can check which version of git you’re using by typing this in your terminal:
git --version
If you use bash (the default shell) edit ~/.bash_profile
or if you’ve installed another shell, edit the configuration file for your specific shell. (Ex. For zsh, edit ~/.zshrc.
)
In your shell configuration file append the following line:
export PATH=/usr/local/bin:$PATH
Restart your terminal and install git via homebrew (a package manager for mac):
brew install git
You’re done! Try git --version
again to see your new git version.
If you ever want to upgrade git in the future, run:
brew upgrade git
Note: If you don’t have homebrew installed, you can install it with this:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"