【问题标题】:Cannot install git through homebrew on yosemite无法在优胜美地上通过自制软件安装 git
【发布时间】:2015-02-24 15:07:45
【问题描述】:

使用自制软件安装 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$ –

忘了说我使用的是 yosemite 10.10.2

【问题讨论】:

  • 自制软件内部不使用 Git 吗?自制软件怎么可能工作(brew update),但运行git --version 表示git 不在您的路径上?你可以尝试从 Bash 而不是 zsh 运行 brew install git 吗?
  • 确实如此。我实际上尝试卸载自制软件,并惊讶地看到它重新安装成功。我会尝试 bash。
  • mymac:~ user$ git --version -bash: git: command not found mymac:~ user$ brew install git Error: git-git already installed 要安装这个版本,首先 `brew unlink git ' mymac:~ 用户$
  • 您的环境有些奇怪。 git-git 的第二部分应该是版本号,以防已安装公式(请参阅github.com/Homebrew/homebrew/blob/…)。如果我在本地运行brew install git,它会显示:Warning: git-2.3.0 already installed。
  • 您可能想在 GitHub 上的 Homebrew 项目中打开一个问题:github.com/Homebrew/homebrew/issues

标签: git homebrew homebrew-cask


【解决方案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 命令,如果不编辑你的路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 2015-06-02
    相关资源
    最近更新 更多