You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS High Sierra下找不到机器级gitconfig文件的原因及查找方法

Why git config --system --list throws an error on macOS High Sierra (pre-installed Git)

First off, don’t worry—this error isn’t a sign your Git installation is broken. Here’s the breakdown:

The pre-installed Git that comes with macOS High Sierra (and most Apple-provided Git versions) doesn’t create the /etc/gitconfig system-level config file by default. This file only exists if it was manually created by you, another user, or an installer that needed to set system-wide Git preferences. The error message is just telling you the file hasn’t been set up yet.

How to handle the system-level gitconfig file:

  • Create it manually: If you want to use system-wide Git settings, you can make the file yourself. Run these commands in Terminal (you’ll need admin privileges):
    sudo touch /etc/gitconfig
    sudo nano /etc/gitconfig
    
    Replace nano with your preferred text editor (like vim) if you want.
  • Verify the expected path: To confirm exactly where Git is looking for the system config, run this command—it will show you the path even if the file doesn’t exist:
    git config --show-origin --system user.name
    
    Even though it’ll throw an error about the missing file, it will still print the path it’s trying to access (which should be /etc/gitconfig for Apple’s pre-installed Git).
  • Note on third-party Git: If you ever install Git via Homebrew or another package manager, the system config path might change (usually to /usr/local/etc/gitconfig), but since you’re using the pre-installed version, stick with /etc/gitconfig.

Remember, your user-level config (~/.gitconfig) works fine because Git automatically creates that file when you set global preferences (like git config --global user.name "Your Name").

内容的提问来源于stack exchange,提问作者Jun Yin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:05:26