homebrew安装软件出现git问题fatal: not in a git directory,Error: Command failed with exit 128: git解决方法

发布时间 2023-09-04 16:27:58作者: yongfengnice

homebrew安装软件出现git问题

问题

fatal: not in a git directory
Error: Command failed with exit 128: git

问题查找

1. brew -v 查看问题log
  suyf@suyfdeMac-mini ~ % brew -v
  Homebrew 4.0.18-18-g64259a4
  fatal: detected dubious ownership in repository at '/opt/homebrew/Library/Taps/homebrew/homebrew-core'
  To add an exception for this directory, call:
  git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
  Homebrew/homebrew-core (no Git repository)

  fatal: detected dubious ownership in repository at '/opt/homebrew/Library/Taps/homebrew/homebrew-cask'
  To add an exception for this directory, call:
  git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
  Homebrew/homebrew-cask (no Git repository)

解决方法

1. 解决方法已经在问题提示里面了。
  第一步执行:git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
  第二步执行:git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask