1

使用自制软件安装 git 时遇到问题。尝试了所有可用的过去解决方案。我确实对 /usr/local 有写权限。我可以毫无问题地进行 brew update 和 brew doctor ,但它说我已经安装了 git-git (无论是什么)。我有 oh-my-zsh shell。如果可能相关,我已经安装了带有 git 和 atom 的 xcode。

Last login: Tue Feb 24 09:56:18 on console
    You have new mail.

# user at mymac in ~ [9:57:48]
$ brew install git
Error: git-git already installed
To install this version, first `brew unlink git'

# user at mymac in ~ [9:57:54]
$ brew unlink git
Error: No such keg: /usr/local/Cellar/git

# user at mymac in ~ [9:58:04]
$ brew update
Updated Homebrew from b33e8a75 to cf5325ac.
==> New Formulae
deisctl         gcovr       pdf-redact-tools
==> Updated Formulae
activemq    couchdb-lucene  hamsterdb   libgadu     redpen
avian       datomic     httpie      libmpdclient    unittest
berkeley-db gtk-gnutella    ice     mysql
cctools     h2o     ipsumdump   mysql-cluster

# user at mymac in ~ [10:01:04]
$ brew doctor
Your system is ready to brew.

# user at mymac in ~ [10:01:25]
$ brew install git
Error: git-git already installed
To install this version, first `brew unlink git'

# user at mymac in ~ [10:01:30]
$ brew unlink git
Error: No such keg: /usr/local/Cellar/git

# user at mymac in ~ [10:01:35]
$ brew link git
Error: No such keg: /usr/local/Cellar/git

# user at mymac in ~ [10:01:44]
$ git --version
zsh: command not found: git

# user at mymac in ~ [10:02:01]
$ brew --version
0.9.5

# user at mymac in ~ [10:06:17]
$ git-git --version
zsh: command not found: git-git

# user at mymac in ~ [10:11:32]
$ which git-git
git-git not found

更新:我尝试将 shell 改回 bash。同样的问题。

mymac:~ user$ git --version 
-bash: git: command not found 
mymac:~ user$ brew install git 
Error: git-git already installed To install this version, first `brew    unlink git' 
mymac:~ user$ –

忘了提我正在使用优胜美地 10.10.2

4

1 回答 1

1

从命令行执行

where git

你可能会得到两个位置

/usr/bin/git
/usr/local/bin/git

然后做

 /usr/bin/git --version

你应该得到

git version 2.5.4 (Apple Git-61)

这是 Mac OS 自带的安装版本

然后检查此路径上的版本

/usr/local/bin/git --version
git version 2.7.1

这是当前版本

然后检查你的路径

echo $PATH

并确保 '/usr/local/bin/' 在你的路径中,否则它不会执行 git 命令,如果不编辑你的路径。

于 2016-07-05T08:12:55.487 回答