How to update git version correctly?

Viewed 6087

I downloaded a new version of git - version 2.26.0 using command:

brew upgrade git But i can't use it! If I type:

git --version
$ git version 2.22.0

If I try to update it again:

brew upgrade git
Warning: git 2.26.0 already installed

How to fix this ?

2 Answers

I used:

brew link --overwrite git

It has overwritten my current version of git to installed by brew - version 2.26.0.

You have two versions of git, one provided by the operating system, one installed by brew. There can be two issues:

  1. The folder where brew puts executables is not in the $PATH.
  2. The folder where brew puts executables is in $PATH but later than the folder where the OS-provided git is, so git from the other folder is executed.

By executing which git you'll see which git is being used.

There are multiple solutions: You may want to put brew folder at the beginning of $PATH, or install brew to a different folder. Check brew documentation for best practices.

Related