无法从终端使用git [英] Cannot use git from terminal
问题描述
我从此处安装了OS X的GitHub UI: https://central.github.com/mac /latest .作为安装的一部分,我可以选择安装命令行工具".这样做会将相关资产放在/usr/local/bin下.我以为它也会在PATH变量中注册git,以便在需要时可以从终端运行它.但是,它在终端上不起作用,相反,如果我在终端上运行"git",则会提示我安装XCode.
I installed the GitHub UI for OS X from here: https://central.github.com/mac/latest. As part of the installation I get an option to "Install Command Line Tools". On doing so it places the relevant assets under /usr/local/bin. I assumed it would register git in the PATH variable as well so that I could run it from the terminal if needed. However it doesn't work from the terminal, instead if I run 'git' in terminal, I get prompted to install XCode.
我在这里假设不正确吗?还尝试从以下位置安装git: http://git-scm.com/download/mac .安装程序成功完成后,我似乎仍然无法在终端上使用git.
Am I assuming something incorrectly here? Also tried installing git from here: http://git-scm.com/download/mac. After the installer completed successfully, I still can't seem to be able to use git from the terminal.
更新:我的PATH变量具有以下内容:
UPDATE: my PATH variable has the following:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
推荐答案
在Mac上的 git中提到:替换Apple XCode CLI git并具有指向最新git install的符号链接?",它紧随PATH
环境变量中文件夹的顺序.
As mentioned in "git on Mac: replace Apple XCode CLI git with symbolic link to latest git install?", it dpeends on the order of the folders in the PATH
environment variable.
- XCode CLI安装程序将git的副本放入
/usr/bin
- 从git-scm.com重新安装最新的git,将git放入
/usr/local/git/bin/git
- XCode CLI installer puts a copy of git in
/usr/bin
- Reinstalling the latest git from git-scm.com put git in
/usr/local/git/bin/git
如果在/usr/local/git/bin
中安装了git命令行,请确保将其放在第一位:
If git command line is installed in /usr/local/git/bin
, make sure to put that in first:
PATH=/usr/local/git/bin:$PATH
这篇关于无法从终端使用git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!