Different versions of Git on Mac OS Yosemite

I guess Git on my macbook was of version 1.8.4, because I tried

git --version
git version 1.8.4

echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

whereis git
/usr/bin/git

later I try to upgrade the latest version of Git to 2.0.1, I download and install from

http://git-scm.com/download/mac

Since this installer installs Git to /usr/local/git, and append the path to $PATH, so now

echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin

I also replace the binary file to /usr/bin/ by

sudo cp /usr/local/git/bin/git /usr/bin/

And I logged out and logged in back, but found the following strange situation:

/usr/bin/git --version
git version 2.0.1

git --version
git version 1.8.4

whereis git
/usr/bin/git

Where does my mac os look for when I type git --version? Where is my previous version 1.8.4 located and how can I delete it and replace it with my new version?

  • How can I set up my own local Git server on my own computer?
  • automatically using -v option for git remote
  • xargs doesn't work on Mac when given output from 'git branch'
  • Xcode 6 + OS X Server 10.10 failing initial push to server
  • Git error: could not commit config file
  • Git make filename's first letter uppercase
  • Initial commit using “git commit -am” failing and causing error when pushing to GitHub
  • View version control progress graphically
  • One Solution collect form web for “Different versions of Git on Mac OS Yosemite”

    The correct way to use another version of git would be to put it first in the path. Edit the file that appends /usr/local/git/bin to the path so that it prepends it instead.

    Most likely there is something like the following in either your ~/.bash_profile or ~/.profile.

    export PATH="$PATH:/usr/local/git/bin"
    

    Change it to:

    export PATH="/usr/local/git/bin:$PATH"
    

    BTW, sudo cp /usr/local/git/bin/git /usr/bin/ is probably not a good idea, as other software may expect the default version to be there. A software update may also replace it.

    Git Baby is a git and github fan, let's start git clone.