how to Uninstall the old version of git on the mac m1?

Issue

i think i have two version of git installed.how i unninstall the old one?

warning: git 2.38.1 is already installed and up-to-date.
To reinstall 2.38.1, run:
  brew reinstall git
[email protected] ~ % git --version
git version 2.15.0
[email protected] ~ % wich git
zsh: command not found: wich
[email protected] ~ % which git
/usr/local/bin/git
[email protected] ~ % git --version
git version 2.15.0
[email protected] ~ % $ /usr/local/bin/git --version
zsh: command not found: $
[email protected] ~ % brew update
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

Updated 1 tap (homebrew/core).
[email protected] ~ % git --version
git version 2.15.0
[email protected] ~ % 

Solution

I see two root causes here (it’s always better to understand why such thing is happening first, rather then just deleting):

  1. Default macos git vs brew-installed git. The thing is, that macOS has some pre-installed git binary, which comes with xcode command line tools, so you probably don’t want to delete those. You can find really good answer here: https://apple.stackexchange.com/questions/304100/is-git-pre-installed-on-macos-sierra
  2. Different shells like bash vs zsh which can have different $PATH configured, so in bash shell you get one version of git in zsh – another.

Answered By – Глеб Иодо

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published