这是从我的 shell 中实际复制/粘贴的:
machine:~ me$ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.2.1.mountain_lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.2.1.mountain_lion.bottle.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
答案1
我不是 Mac/homebrew 专家,但通常情况下,当你安装时,它只是将 git 解压到它自己的、特定于版本的目录中。/usr/bin/git 可能是指向所述特定版本目录中实际 git 二进制文件的符号链接。在这种情况下,你需要做的就是取消链接 /usr/bin/git 并重新创建指向较新目录的链接。如果我不知道你的目录树,让我猜测命令,它会是这样的:
unlink /usr/bin/git
ln -s /usr/local/Cellar/git/2.2.1/bin/git /usr/bin/git
答案2
试一试export PATH="/usr/local/bin:$PATH"
。如果有效,将其添加到你的 .bashrc 文件中