When executing brew install on Mac, Error: Command failed with exit 128: git

The error is reported as follows

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

Execute repair code

Insert image description here
Executing the following codes in sequence will be slower because the downloaded file is larger and is on a foreigner's website:

git -C "/opt/homebrew" remote set-url origin https://github.com/Homebrew/brew
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-cask"
brew tap homebrew/cask
rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core

Guess you like

Origin blog.csdn.net/Fine_Cui/article/details/126480494