使用homebrew 报错:fatal: not in a git directory Error: Command failed with exit 128: git

使用homebrew 报错:fatal: not in a git directory Error: Command failed with exit 128: git

提示:关注公众号:小千哥,协助解决各种技术问题!

报错如下:

 ~  brew install nginx
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask, skipping update!
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core, skipping update!
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Homebrew has enabled anonymous aggregate formula and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).
 
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
Running `brew update --preinstall`...
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/openssl%401
Already downloaded: /Users/sunkeo/Library/Caches/Homebrew/downloads/fc4281b06e29b8c638b7f3b55da7ab003aef9fcb9f92365ca6f2363d3c07fb40--openssl@1.1-1.1.1o.monterey.bottle.tar.gz
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/nginx-1.21.
Already downloaded: /Users/sunkeo/Library/Caches/Homebrew/downloads/5582b7ccc9d76be29176ce182ce68534fb57ac5fa81a8a4f179ee6a0d323b4f8--nginx-1.21.6_1.monterey.bottle.tar.gz
==> Installing dependencies for nginx: openssl@1.1
==> Installing nginx dependency: openssl@1.1
fatal: not in a git directory
Error: Command failed with exit 128: git
 

解决方式

执行brew -v 命令看看是不是有两个提示,你的 homebrew-core和homebrew-cask目录 被git认为不是一个安全的目录,需要手动添加,关注公众号:小千哥
git config --global --add safe.directory 你的homebrew-core路径
git config --global --add safe.directory 你的homebrew-cask路径
关注公众号:小千哥

你可能感兴趣的:(php,nginx,php)