Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade Git to latest version on macOS?

Tags:

git

macos

People also ask

What is the latest git version for Mac?

The latest version is 2.33.0, which was released 12 months ago, on 2021-08-30.

How do I check git version on Mac?

Check your version of Git You can check your current version of Git by running the git --version command in a terminal (Linux, macOS) or command prompt (Windows).


It's simple if you already have Homebrew: Assuming you have homebrew installed, type the following:

brew install git

This should automatically install git and set it in your path, replacing the Apple one.

Now quit and restart your terminal.

Then check git version to confirm.

git --version

If the output of the above command shows the latest version and does not mention Apple with the version details, then you are all set.

If however you still see apple version, then type the following two lines, which will manually 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

Quit terminal and open a new terminal, 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


It would probably be better if you added:

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

to a file named .bashrc in your home folder. This way any other software that you might install in /usr/local/git/bin will also be found first.

For an easy way to do this just type:

echo "export PATH=/usr/local/git/bin:/usr/local/sbin:$PATH" >> ~/.bashrc

into the Terminal and it will do it for you.


if using homebrew you can update sim links using

brew link --overwrite git

For me, with Homebrew 1.6.7, the following worked:

brew upgrade git