'Updated Git on Mac & old version still showing

I've had Git on my Mac for a while (previously downloaded and installed it from the Git website some time ago). Today I decided I wanted to update Git - I ended up installing homebrew and running $brew install git which all seemed to work fine.

The problem I have is that $git --version is still showing the older version (git version 2.21.0). So I think I've got 2 Git installations on my machine and it's using the old one?

$which git gives: /usr/local/bin/git

$echo $PATH gives: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

I'm no expert, but this looks really wrong?!

From poking around in the file structure I find the following folder, which looks like the new install of Git: /usr/local/Cellar/git/2.30.1

Can anyone tell me how I can fix this mess? Much appreciated :)



Solution 1:[1]

In my case, the changes in $PATH settings didn't work. Always got the Apple version when doing git --version.

What worked for me was: brew link --overwrite git

After that, I got the version of brew installed git.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christian Osswald