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

  • Fetching all remote branches into a bare Git repository
  • On this workflow, does git command needs to be installed on the production server?
  • git-tfs: A shelved pending change on a file is required
  • Git: How do I push objects created with git hash-object back to origin?
  • More clever git filter-branch --subdirectory-filter
  • VS 2013 + Git + Visual Studio Online + multiple Repos in one project
  • 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?

  • Git : Merging Issues with Git
  • What is the diff version git use? diff2 or diff3?
  • Git asks for password for each commit and pull
  • How to use the forked repo and still track updates from the original source
  • GIT Error:- expected committer email '' but found 'karan@xyz.com'
  • What is branched in a repository?
  • 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.