Search code examples
gitmacosuninstallation

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


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
vlad@vlads-Air ~ % git --version
git version 2.15.0
vlad@vlads-Air ~ % wich git
zsh: command not found: wich
vlad@vlads-Air ~ % which git
/usr/local/bin/git
vlad@vlads-Air ~ % git --version
git version 2.15.0
vlad@vlads-Air ~ % $ /usr/local/bin/git --version
zsh: command not found: $
vlad@vlads-Air ~ % brew update
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

Updated 1 tap (homebrew/core).
vlad@vlads-Air ~ % git --version
git version 2.15.0
vlad@vlads-Air ~ % 

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.