.gitignore_global 在 OS X 上保存在哪里?

Where is .gitignore_global saved on OS X?

我通过 运行

创建了一个 .gitignore_global 文件
git config --global core.excludesfile ~/.gitignore_global

但是,我在我的文件系统中找不到相关文件?它保存在哪里?

I have created a .gitignore_global file using the command [...]

命令

git config --global core.excludesfile ~/.gitignore_global

创建任何文件。换句话说,如果 ~/.gitignore_global 事先不存在,运行 该命令不会创建它。

该命令的语义是

Set the path of the user-level (because of the --global flag) Git ignore file to ~/.gitignore_global.

在实现方面,该命令添加了以下条目

excludesfile = ~/.gitignore_global

~/.gitconfig 文件的 core 部分下,这是 user-level 配置文件的默认路径。有关 Git 配置文件的三个级别(系统、用户、存储库)的更多详细信息,请参阅 this section of the Pro Git book

您可以在终端中通过运行此命令找到文件位置:

git config --get core.excludesfile

在终端中:(macOS Catalina)

  1. touch ~/.gitignore_global
  2. open .gitignore_global 添加:.DS_Store
  3. git config --global core.excludesfile ~/.gitignore_global

大功告成