[macos] How to upgrade Git to latest version on macOS?

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:

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?