mac m1解决brew安装包时fatal: not in a git directoryError: Command failed with exit 128: git

问题描述

mac m1使用brew装tree时,报错如下:

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
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
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
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
fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-services' 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-services
fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-services' 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-services
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
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
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
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
fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-services' 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-services
fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-services' 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-services
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/tree-1.8.0.arm64_monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404

Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/tree/manifests/1.8.0
Already downloaded: /Users/wliang/Library/Caches/Homebrew/downloads/50ac34dbf0d30c786b9255ea5de2d02ba4fc68733b8030e3cbb19ce982d20200--tree-1.8.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/tree/blobs/sha256:ef081c81d87232951eff9f5bed6a589dbe3bd2b16f59e7ae28fdcc5351882429
Already downloaded: /Users/wliang/Library/Caches/Homebrew/downloads/99c1ff68d2ecd33583f4573c655a1eaeccce24d5550b9ece2078af3a58c5a40f--tree--1.8.0.arm64_monterey.bottle.tar.gz
fatal: not in a git directory
Error: Command failed with exit 128: git

brew -v显示

Homebrew 3.3.7-38-g6295b08
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

你可能感兴趣的:(mac使用,macos,git)