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

また、_カスタム フィールド名に 's を使用しないでください。Git はそれらを解析しません:

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