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

whereis git

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

  • TeamCity pass parameter from server to build agent
  • How to keep two repositories synced, in which one repository is child of the other?
  • Differentiated access rights in distributed VCS's
  • git: fatal: bad default revision 'HEAD' with all new repos
  • Delete a branch starting with a hyphen
  • github submodule access rights (Travis CI)
  • 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

    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

    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?

  • What does “would be overwritten by merge” mean?
  • Git diff different directories across branches
  • Github multiple accounts one computer always sees one account
  • Getting Git-concept of “stage”
  • Git commit all files using single command
  • Possible to migrate an SVN repo to git that is a local copy only?
  • 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.