[Solved] Mac M1 Brew install Error: Command failed with exit 128:git

Question:

As shown in the figure, execute brew install redis and report an error: Command failed with exit 128:git

Solution:

After entering brew -v, you will be prompted to execute two configuration commands. It is OK to copy and execute directly!

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core

See the following figure for details

Read More: