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.
-
Check which git you're running:
which git
output should be similar to this: /usr/bin/git
-
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
brew uninstall git
brew update
brew install git
Check which git you're now running:
which git
Should now say: /usr/local/bin/git
@smeeklai, shouldn't need to reboot, though it won't hurt. You just need to restart your terminal as @martbe first pointed out (assuming you previously had Xcode's git installed).
I showed above the problems that happen and why that's necessary. I'm not sure the technical reasoning but I believe it has to do with Xcode's utilities seeking commands that essentially bypass what you have in PATH. Restarting the terminal fixes that.
So a restart of machine will work but all that is (or should be) needed is a restart of your terminal.