Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Re-installing Git on Mac OSX with Brew

Re-installing Git on Mac OSX with Brew

This is helpful if you've previously installed git from source on OSX, and other compilers can't find the correct path. You need to remove the current version of git, then re-install with brew.

Uninstall git if installed manually

  1. Check which git you're running:

    which git
    

    output should be similar to this: /usr/bin/git

  2. Remove that git install

    sudo rm -rf /usr/bin/git/
    sudo rm /etc/paths.d/git
    sudo rm /etc/manpaths.d/git
    sudo pkgutil --forget --pkgs=GitOSX\.Installer\.git[A-Za-z0-9]*\.[a-z]*.pkg
    
    
    

Re-install git with brew

brew uninstall git
brew update
brew install git

Check which git you're now running:

which git

Should now say: /usr/local/bin/git

@yilliot

This comment has been minimized.

Copy link

commented Mar 31, 2018

sudo rm -rf /usr/bin/git wont work for El Capitan due to SIP restriction

simple solution is create alias

alias git='/usr/local/bin/git'

@kungfumike

This comment has been minimized.

Copy link

commented Jun 1, 2018

If you would like to follow the above instructions on a system with SIP enabled:
https://apple.stackexchange.com/questions/248220/how-to-remove-default-git-or-update-it

@novonimo

This comment has been minimized.

Copy link

commented Dec 29, 2018

consider that for change in bin folder (which is read-only) you must disable SIP System Intergradation Protection in your mac:
1- reboot your mac
2- press and hold ⌘ R until seeing the apple's logo
3- from recovery menu utils>Terminal

csrutil disable
reboot

now you can remove bin's stuff
note that: after this change re-enables it using this command:
csrutil enable

@sidonaldson

This comment has been minimized.

Copy link

commented Mar 14, 2019

sudo rm -rf /usr/bin/git wont work for El Capitan due to SIP restriction

simple solution is create alias

alias git='/usr/local/bin/git'

brew does this anyways :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.