4

我有以下.gitconfig:

[user]
name = name
email = email@email.com
custom_field = AAA

使用 git 的内置命令可以轻松获取姓名和电子邮件。

如何获取 custom_field 的值?

4

1 回答 1

8

您的命令失败,因为您在自定义字段的名称中添加了下划线。要将自定义字段添加到.gitconfig文件,请使用以下命令:

git config --global user.customfield <value>

然后,您可以使用以下方法检索它:

git config --global user.customfield

例如:

$ git config --global user.customfield test
$ git config --global user.customfield
test

此外,请避免_在自定义字段名称中使用 '。Git 不解析它们:

$ git config user.custom_field test
error: invalid key: user.custom_field
于 2012-07-06T14:36:40.207 回答