当我尝试使用刚通过自制软件安装的最新版本的git时,遇到了一个非常奇怪的问题。which git
指向我进行自制安装,但是调用git
返回的是与OS X一起安装的原始版本。
我首先检查了一下原来的版本。
[user@home ~]$ git --version
git version 1.8.5.2 (Apple Git-48)
然后我去自制软件安装最新版本。
[user@home ~]$ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.0.0.mavericks.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring git-2.0.0.mavericks.bottle.2.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain
The 'contrib' directory has been installed to:
/usr/local/share/git-core/contrib
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completion has been installed to:
/usr/local/share/zsh/site-functions
==> Summary
🍺 /usr/local/Cellar/git/2.0.0: 1324 files, 31M
看起来很有效!检查它是否指向正确的git
[user@home ~]$ which git
/usr/local/bin/git
应该不错吧?没那么快
[user@home ~]$ git --version
git version 1.8.5.2 (Apple Git-48)
那真是怪了。我真的指向正确的git吗?
[user@home ~]$ ls -l /usr/local/bin/git
lrwxr-xr-x 1 user group 27 Jul 3 15:54 /usr/local/bin/git -> ../Cellar/git/2.0.0/bin/git
当然看起来像。手动调用时有效
[user@home ~]$ /usr/local/Cellar/git/2.0.0/bin/git --version
git version 2.0.0
但是不像 git
[user@home ~]$ which git
/usr/local/bin/git
[user@home ~]$ git --version
git version 1.8.5.2 (Apple Git-48)
关于什么可能导致此的任何想法?
编辑:解决了。source .bashrc
固定它。仍然好奇为什么which
会返回正确的可执行文件给我,但是如果有人能解释的话它不会被调用。
$PATH
。