Git出现错误(-bash: git: command not found)

5

我使用 git 命令时遇到了问题,提示 -bash: git: command not found。 但是当我运行 $ gem list 时,它显示已经安装,并且我已将其路径添加到了我的.profile中,如下所示。我不明白为什么它不起作用。谢谢帮助。

# MacPorts Installer addition on 2012-10-11_at_19:01:44: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export PATH=${PATH}:/usr/local/mysql/bin

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

# git path

export PATH=$PATH:/usr/local/git/bin

我已经通过${PATH}更改了$PATH,但它仍然无法工作。 - skip87
1
你确定 git 已经安装在 /usr/local/git/bin 目录下了吗?你只是需要将 /usr/local/bin 加入 PATH 路径中吗?在修改过 .profile 文件后,你已经重新加载过它了吗(_source ~/.profile_)? - guido
我该如何首先安装 Git?我的 gems 没有显示任何已安装的 git。 - Hugo
2个回答

3
你安装的git是一个Ruby Gem,用于从Ruby中访问Git功能。它不包含实际的Git,因此不包括命令行git(实际上我甚至不确定Gem是否需要安装正常的Git)。
所以你需要下载并安装Git本身

0
在Mac上: 最好的解决方案是安装Xcode,然后打开Xcode - 首选项,再选择下载。 在这里安装命令行工具,你就可以开始了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接