Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I insert and retrieve a custom field into a .gitconfig file?

Tags:

git

I have the following .gitconfig:

[user]
name = name
email = [email protected]
custom_field = AAA

Getting name and email is easy using git config.

How can I get the value of custom_field :

$ git config --global user.custom_field 
error: invalid key: user.custom_field
like image 490
Alex Avatar asked Feb 19 '23 22:02

Alex


1 Answers

Your command is failing because you've put an underscore in the custom field's name. To add a custom field to the .gitconfig file, use this command:

git config --global user.customfield <value>

You can then retrieve it with:

git config --global user.customfield

For example:

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

Also, avoid _'s in the custom field name. Git doesn't parse them:

$ git config user.custom_field test
error: invalid key: user.custom_field
like image 64
Christopher Avatar answered Feb 23 '23 00:02

Christopher