Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem updating Git on my Mac using VScode

So basically i'm tryiing to update git on my Mac, i'm using VScode with one of the terminals propped up as powershell, and so i check the version of it using the command

git --version

What I got from it was

git version 2.15.0

So I had assumed that I hadn't updated it so I went along and used the command

brew upgrade git

and I get a response saying "Warning: git 2.34.1 already installed", and I check up on it again and the git version is still at 2.15.0

Any thoughts on how I could fix this?

like image 532
Jahanzeb Ahmad Avatar asked Oct 18 '25 02:10

Jahanzeb Ahmad


2 Answers

Hey guys thank you for all those who commented what to do and what's going on, so ultimately while playing around with it for a while this was what I was able to do!

So I go into my terminal and ran brew install git

After that I got this reply in the terminal as follows

Linking /usr/local/Cellar/git/2.34.1... 
Error: Could not symlink bin/git
Target /usr/local/bin/git
already exists. You may want to remove it:
  rm '/usr/local/bin/git'

To force the link and overwrite all conflicting files:
  brew link --overwrite git

To list all files that would be deleted:
  brew link --overwrite --dry-run git 

So I went and ran the command

brew link --overwrite git

The reply i got was :

Linking /usr/local/Cellar/git/2.34.1... 213 symlinks created.

Ran the following command afterwards

brew link --overwrite --dry-run git

Got the following reply back :

Warning: Already linked: /usr/local/Cellar/git/2.34.1

To relink, run:
brew unlink git && brew link git

So I finally ran a check to see what the git version was

git --version

And I got the updated git version I was trying to get my path aligned to!

git version 2.34.1

Hope this helps anyone else who needs help with this! I did not remove '/usr/local/bin/git' but hopefully I didn't need to or won't have to worry about it later on.

like image 184
Jahanzeb Ahmad Avatar answered Oct 20 '25 22:10

Jahanzeb Ahmad


You would need to make sure homebrew/bin folder is first in your $PATH (on macOS Monterey):

export PATH=/opt/homebrew/bin:$PATH

Then a git --version would return the expected latest version.
You have various options explained here, like adding alias git="/usr/local/bin/git" to your .zshrc or .bashrc.

like image 30
VonC Avatar answered Oct 20 '25 21:10

VonC