brew安装时fatal: not in a git directory Error: Command failed with exit 128: git

This error occurs when installing node using brew

insert image description here

Guess the reason:

应该是homebrew没有找到git路径,因此我们需要配置一下

ps: Most of the reference materials are directly git binding homebrew under the usr/local/ path, here we need to configure our own local path

solution

  1. Find Homebrew installation location

    • Here I am usingfind / -name "homebrew-cask"
    • Find the following similar paths
      insert image description here
    • It is recommended to open this directory to see if it is the following three directories at the same level as this directory
      insert image description here
  2. git bind homebrew path

    • git config --global --add safe.directory 自己的homebrew-core目录
    • git config --global --add safe.directory自己的homebrew-cask目录
  3. Check to see if the addition is complete
    git config --global --list
    insert image description here
    , so the configuration is successful.

ps: If you have configured other directories before, it is recommended to find .gitconfig and delete others.
Find the gitconfig command:git config --global --list --show-origin

insert image description here

Guess you like

Origin blog.csdn.net/Quiet_tomcat/article/details/127327654