After installing homebrew, run brew -v
hint
Homebrew 4.0.6-186-g98a2923
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)
In fact, the root directory of homebrew does not trust Homebrew/homebrew-core (no Git repository) and Homebrew/homebrew-cask (no Git repository), how to solve the above problems.
Just follow the prompts to run these two command lines
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
After running these two, check the version again, brew -v, you can see the two version prompts
brew -v
Homebrew 4.0.6-186-g98a2923
Homebrew/homebrew-core (git revision 5eaa252887b; last commit 2023-03-20)
Homebrew/homebrew-cask (git revision 51351c7c47; last commit 2023-03-20)