Use git--version to view git versions in terminal, often not the latest version.
Download the latest git version from the GIT website http://git-scm.com/, after the installation path is:/usr/local/git/bin/git. But the result returned with the which git command is/usr/bin/git, and the version does not change. Using the Echo $PATH to view the path, the results are as follows:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/x11/bin:/usr/local/git/bin
/usr/bin is ranked before/usr/local/git/bin, so the old git version is used by default
Method One:
Refer to the article (what it was and how to Modify the Shell path in OSX 10.10 Yosemite using Terminal) method to modify the shall path
1. Create a. bash_profile file with the editor nano using the command line , i.e. enter the following command in Terminal
<span style= "Font-family:microsoft yahei;font-size:14px;" >nano .bash_profile</span>
2, add the following, enter:
Export path= "/usr/local/git/bin: $PATH"
Then press "Ctrl+o" to save, then press "return" (enter) to confirm, and then press "Ctrl+x" to exit
3, re-login terminal, with "echo $PATH" to view the path, the results are as follows:
/usr/local/git/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/x11/bin
Use new version by default
Method Two: Remove the system's own version ( refer to article: How to: Upgrade Git on mac OS x)
Cd/usr/bin
sudo mkdir backup-git-apple
sudo mv git* backup-git-apple
Upgrading Git on Mac OS x