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

本文讲述了在Arch架构的arm64平台上使用Homebrew安装CocoaPods时遇到的git错误,并提供了设置安全目录以解决.git权限问题的详细步骤,确保了后续的brew install顺利进行。
摘要由CSDN通过智能技术生成

arch -arm64 brew install cocoapods 报错 fatal: not in a git directory Error: Command failed with exit 128: git

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

如下:

➜ arch -arm64 brew install cocoapods
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-cask, skipping update!
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-core, skipping update!
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Warning: Treating cocoapods as a formula. For the cask, use homebrew/cask/cocoapods
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/ca-certificates-2022-04-26.all.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1o.arm64_monterey.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/readline-8.1.2.arm64_monterey.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/ruby-3.1.2.arm64_monterey.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/cocoapods-1.11.3.arm64_monterey.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for cocoapods: ca-certificates, openssl@1.1, readline and ruby
==> Installing cocoapods dependency: ca-certificates
fatal: not in a git directory
Error: Command failed with exit 128: git

解决办法:

brew -v 查看会有两个提示,提示用户设置 homebrew-caskhomebrew-core 的文件路径为设置为safe.directory, 即使用如下命名:

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

之后再执行 arch -arm64 brew install cocoapods 即可,操作如下

~ brew -v
Homebrew 3.4.11
fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else)
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: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else)
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)~ 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
➜  ~ brew -v                                                                                   
Homebrew 3.4.11
Homebrew/homebrew-core (git revision e913920c28f; last commit 2022-05-18)
Homebrew/homebrew-cask (git revision 17edd4ce59; last commit 2022-05-18)~ arch -arm64 brew install cocoapods                                                        
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Warning: Treating cocoapods as a formula. For the cask, use homebrew/cask/cocoapods
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/ca-certificates-2022-04-26.all.bottle.tar.gz
Already downloaded: /Users/morris/Library/Caches/Homebrew/downloads/66ab11fb867e9c78860f502908686ed6f07cb9ecdae61bdeab62941e7c8a499c--ca-certificates-2022-04-26.all.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1o.arm64_monterey.bottle.tar.gz
Already downloaded: /Users/morris/Library/Caches/Homebrew/downloads/e3aecc896492e01daa0070a88ed73d200d10e4b8073faf09aa0c9be6209466b1--openssl@1.1-1.1.1o.arm64_monterey.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/readline-8.1.2.arm64_monterey.bottle.tar.gz
Already downloaded: /Users/morris/Library/Caches/Homebrew/downloads/39a84bfc99390b41af3e6aa9252a345e71111216ca4365ac1356c989d9b5994e--readline-8.1.2.arm64_monterey.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/ruby-3.1.2.arm64_monterey.bottle.tar.gz
Already downloaded: /Users/morris/Library/Caches/Homebrew/downloads/40fd5625e22759f6659af43db2d4e490677d1a69d8daa88f5aca0e42a4658a81--ruby-3.1.2.arm64_monterey.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/cocoapods-1.11.3.arm64_monterey.bottle.tar.gz
Already downloaded: /Users/morris/Library/Caches/Homebrew/downloads/2a567318ae0c575fe9cce953ae04e584427d01a6a536575471a115d612d909a1--cocoapods-1.11.3.arm64_monterey.bottle.tar.gz
==> Installing dependencies for cocoapods: ca-certificates, openssl@1.1, readline and ruby
==> Installing cocoapods dependency: ca-certificates
==> Pouring ca-certificates-2022-04-26.all.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /opt/homebrew/Cellar/ca-certificates/2022-04-26: 3 files, 215.6KB
==> Installing cocoapods dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1o.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/openssl@1.1/1.1.1o: 8,089 files, 18MB
==> Installing cocoapods dependency: readline
==> Pouring readline-8.1.2.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/readline/8.1.2: 48 files, 1.7MB
==> Installing cocoapods dependency: ruby
==> Pouring ruby-3.1.2.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/ruby/3.1.2: 15,996 files, 42.8MB
==> Installing cocoapods
==> Pouring cocoapods-1.11.3.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/cocoapods/1.11.3: 13,496 files, 28.3MB
==> Running `brew cleanup cocoapods`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
评论 29
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Morris_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值