使用homebrew 報(bào)錯(cuò):fatal: not in a git directory Error: Command failed with exit 128: git
提示:關(guān)注公眾號(hào):小千哥芽偏,協(xié)助解決各種技術(shù)問(wèn)題堪置!
報(bào)錯(cuò)如下:
~ 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
解決方式:
執(zhí)行brew -v 命令看看是不是有兩個(gè)提示观蓄,你的 homebrew-core和homebrew-cask目錄 被git認(rèn)為不是一個(gè)安全的目錄,需要手動(dòng)添加暇韧,關(guān)注公眾號(hào):小千哥
git config --global --add safe.directory 你的homebrew-core路徑
git config --global --add safe.directory 你的homebrew-cask路徑
關(guān)注公眾號(hào):小千哥