How to upgrade Git to latest version on macOS?

前端 未结 15 1837
离开以前
离开以前 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:52

    Without Homebrew

    1. Use the installer from git's website.
    2. Update your ~/.bash_profile file. Notice this command differs from kmikael's answer by what it puts in the file:
      • Other command: export PATH=/usr/local/git/bin:/usr/local/sbin/:[and so on]
      • Below command: export PATH="/usr/local/git/bin:/usr/local/sbin:$PATH"
      • Use whichever one you prefer.

    echo 'export PATH="/usr/local/git/bin:/usr/local/sbin:$PATH"' >> ~/.bash_profile

    1. If you're using Xcode, you'll need to add some symbolic links.
      • Example: ln -s /opt/local/bin/git /usr/bin/git
    2. Restart terminal.
      • which git should say the directory in the README.txt file from the dmg.
      • git --version should say the updated version.
      • echo $PATH should start with /usr/local/git/bin:/usr/local/sbin:

提交回复
热议问题