How to upgrade Git to latest version on macOS?

前端 未结 15 1836
离开以前
离开以前 2020-12-02 03:57

I just bought a new Mac with OS X Lion and I checked in the Terminal what version of git is installed by default. I got the answer

git --version
> git ver         


        
15条回答
  •  暖寄归人
    2020-12-02 04:31

    I used the following to upgrade git on mac.

    hansi$ brew install git 
    
    hansi$ git --version 
    git version 2.19.0
    
    
    hansi$ brew install git
    Warning: git 2.25.1 is already installed, it's just not linked
    You can use `brew link git` to link this version.
    
    hansi$ brew link git 
    Linking /usr/local/Cellar/git/2.25.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
    
    hansi$ brew link --overwrite git 
    Linking /usr/local/Cellar/git/2.25.1... 205 symlinks created
    
    
    hansi$ git --version
    git version 2.25.1
    

提交回复
热议问题