Execute the brew -v command to see if there are two prompts. Your homebrew-core and homebrew-cask directories are not considered a safe directory by git and need to be added manually
If the above error occurs, execute the git command to solve it! (pro-test is effective)
git config --global --add safe.directory 你的homebrew-core路径
git config --global --add safe.directory 你的homebrew-cask路径