Homebrew致命错误:需要一个单一修订版本(MacOs Sierra)

31

我不确定这个问题是否与升级到MacOs Sierra有关,但自从那时起,当我运行“brew update”时就会出现这个错误。


→ brew update
Checking out v1.0.0 in /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask...
To checkout master in /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask run:
  'cd /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask && git checkout master
fatal: Cannot update paths and switch to branch 'v1.0.0' at the same time.
Did you intend to checkout 'refs/tags/1.0.0' which can not be resolved as commit?
fatal: Needed a single revision
invalid upstream refs/tags/1.0.0
Checking out v1.0.0 in /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart...
To checkout master in /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart run:
  'cd /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart && git checkout master
fatal: Cannot update paths and switch to branch 'v1.0.0' at the same time.
Did you intend to checkout 'refs/tags/1.0.0' which can not be resolved as commit?
fatal: Needed a single revision
invalid upstream refs/tags/1.0.0
Checking out v1.0.0 in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
To checkout master in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core run:
  'cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git checkout master
fatal: Cannot update paths and switch to branch 'v1.0.0' at the same time.
Did you intend to checkout 'refs/tags/1.0.0' which can not be resolved as commit?
fatal: Needed a single revision
invalid upstream refs/tags/1.0.0

我尝试运行

cd $(brew --prefix) && git fetch && git reset --hard origin/master

但它给我这个错误:

fatal: Not a git repository (or any of the parent directories): .git

1
我也遇到了这个问题,但我还没有升级到Sierra。不过,我已经升级到Brew 1.0。 - SCdF
5个回答

60

我在升级到 Sierra 后遇到了同样的问题。

除了显示 Homebrew 安装路径的 brew --prefix,还有一个显示其 .git 目录所在位置的命令 brew --repository

man brew 中指出:“对于标准安装,前缀和存储库是相同的目录”。但要么是该手册不是最新版本,要么就是我的安装不是“标准”的。因为我的 prefix/usr/local,而我的 repository/usr/local/Homebrew

使用相同的命令,但加上 cd $(brew --repository) 对我有用:

cd $(brew --repository) && git fetch && git reset --hard origin/master

10
完整修复:cd $(brew --prefix)/Homebrew && git fetch && git reset --hard origin/master。(注:这是针对 Homebrew 的命令,用于修复可能出现的各种问题。) - Iurii Tkachenko
4
AKA brew --repository - robertklep
1
谢谢@thomasd,这解决了我的问题! - Martin van Houte
Homebrew 最近(本周)从 /usr/local 迁移到了 /usr/local/Homebrew,文档可能仍然过时。 - Ben XO
这也会破坏那些在(brew --prefix)中源代码完整性的脚本。 - orome
显示剩余3条评论

3
接受的答案对我没有用。有效的方法是卸载 homebrew 并重新安装它:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew analytics off

1
这个命令对我解决了错误:
```html

这个命令对我解决了错误:

```
git -C $(brew --repository homebrew/core) checkout master

0

卸载


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

然后重新安装。


0

对我来说,没有什么真正有效的方法,我不得不采取卸载和重新安装Brew的方法:

# change to home directory to avoid other errors later
cd ~

# uninstall brew
rm -rf /usr/local/Cellar /usr/local/.git && cd ~ && brew cleanup

 # reinstall brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

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