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

brew install carthage报错:

~ % brew install carthage
fatal: not in a git directory
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask, skipping update!
fatal: not in a git directory
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core, skipping update!
fatal: not in a git directory
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/carthage-0.
Already downloaded: /Users/zhjch/Library/Caches/Homebrew/downloads/60e742acea5cf0209980e5b24fa584df489180e83397778e5ef9d002041d13dd--carthage-0.38.0.monterey.bottle.tar.gz
fatal: not in a git directory
Error: Command failed with exit 128: git

解决办法:
执行命令brew-v,会有如下提示,提示用户设置设置homebrew-core和homebrew-cask的文件路径为safe.directory

 ~ % brew -v
Homebrew 3.5.10-74-gd5b9d0e
fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'
To add an exception for this directory, call:

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

    git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)

即执行如下命令:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask

之后再执行 brew install carthage即可。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容