在出现 Homebrew 错误的 macOS 上安装 git

Installing git on macOS with Homebrew Error

我已经在 macOS 上安装了 HomeBrew,但是当我尝试从命令安装 git 时:

brew install git

终端弹出此错误:

Updating Homebrew...

Error: The following directories are not writable by your user:
/usr/local/share/zsh /usr/local/share/zsh/site-functions

You should change the ownership of these directories to your user.  
sudo chown -R $(whoami) /usr/local/share/zsh
/usr/local/share/zsh/site-functions

我不太明白这个程序到底想让我说什么。任何帮助都是有用的。

正在说运行这个命令

sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions