mac 使用brew安装提示fatal: not in a git directory Error: Command failed with exit 128: git

Posted 污昂博奥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac 使用brew安装提示fatal: not in a git directory Error: Command failed with exit 128: git相关的知识,希望对你有一定的参考价值。

在使用brew 安装scrcpy的时候出现以下问题:

==> Installing dependencies for scrcpy: dav1d, frei0r, bdw-gc, libffi, pkg-config, guile, libtasn1, nettle, p11-kit, libevent, unbound, gnutls, lame, fribidi, pcre, python@3.9, glib, libpthread-stubs, xorgproto, libxau, libxdmcp, libxcb, libx11, libxext, libxrender, lzo, pixman, cairo, gobject-introspection, graphite2, harfbuzz, libass, libbluray, cjson, cmocka, mbedtls, librist, libsoxr, libvidstab, libogg, libvorbis, libvpx, opencore-amr, little-cms2, openjpeg, opus, rav1e, flac, libsndfile, libsamplerate, rubberband, sdl2, snappy, speex, srt, leptonica, libb2, lz4, libarchive, tesseract, theora, x264, x265, xvid, zeromq, zimg, ffmpeg and libusb
==> Installing scrcpy dependency: dav1d
fatal: not in a git directory
Error: Command failed with exit 128: git

经过一番折腾,记录以下解决方式:
通过brew -v命令来查看下是否有以下提示:

Homebrew 3.4.10-54-g987e688
fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else)
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: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else)
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

问题找到解决方式之后,就感觉其实很简单。

以上是关于mac 使用brew安装提示fatal: not in a git directory Error: Command failed with exit 128: git的主要内容,如果未能解决你的问题,请参考以下文章

Mac系统下安装Homebrew后无法使用brew命令,-bash: brew: command not found

解决mac安装homebrew后报错-bash: brew: command not found

Mac终端出现 brew command not found 解决

Mac 终端报错 zsh: command not found: brew 解决方案

mac环境下brew command not found错误的解决方法

Mac M1开发环境的安装与配置(Homebrew)