Home > Mobile >  Problem updating Git on my Mac using VScode
Problem updating Git on my Mac using VScode

Time:01-21

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?

CodePudding user response:

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.

CodePudding user response:

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 instal 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 alligned 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.

  •  Tags:  
  • Related