Can't use homebrew installed git

Shells maintain a cache of the paths where executables were found in the $PATH variable. So it cached /usr/bin/git rather than /usr/local/bin/git, because the latter didn't exist when your shell started. Running hash -r in Bash from your current terminal will clear this cache, then the first instance found in $PATH should be the one that executes.


I got the exact same problem. Here is my solution.

brew uninstall git
# make sure everything is alright, maybe brew will give you some hint
brew doctor
brew update  
brew install git
# magic happen, brew will give you hint /usr/bin occurs before /usr/local/bin
# and recommend you run following command
brew doctor
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

After that you are done, however you are not able to see any changes when you run git --version. Just log out and log back in, run git --version again.