欢迎光临
专注前后端开发技术与经验分享

mac使用brew安装报错fatal: not in a git directory

刚上手mac系统,打算安装nvm时,brew上来就给我邦邦两拳

mac@macdeMBP ~ % brew install nvm
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Fetching nvm
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles//nvm-0.39.
Already downloaded: /Users/mac/Library/Caches/Homebrew/downloads/2ae500a8baea60fbb1e274d5c0a606f4eb3f4f7a68795e4d0d5791460e01b457--nvm-0.39.3.all.bottle.tar.gz
fatal: not in a git directory
Error: Command failed with exit 128: git

大概意思就是brew的安装目录被git认为不是一个安全的目录,需要手动添加信任,解决方案:打开终端输入

brew -v

然后你会看到:

mac@macdeMBP ~ % brew -v
Homebrew 4.0.9-75-gc271a9a
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)

复制上面的命令提示,分别输入:

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

然后完美解决~

赞(1) 打赏
未经允许不得转载:杰哥博客 » mac使用brew安装报错fatal: not in a git directory

觉得文章有用就打赏杰哥一杯可乐吧~

支付宝扫一扫打赏

微信扫一扫打赏