2
我有以下的.gitconfig:如何插入和檢索自定義字段到.gitconfig文件中?
[user]
name = name
email = [email protected]
custom_field = AAA
獲取名稱,並使用內置的命令Git的電子郵件很容易。
如何獲取custom_field的值?
我有以下的.gitconfig:如何插入和檢索自定義字段到.gitconfig文件中?
[user]
name = name
email = [email protected]
custom_field = AAA
獲取名稱,並使用內置的命令Git的電子郵件很容易。
如何獲取custom_field的值?
您的命令失敗,因爲您在自定義字段的名稱中加了下劃線。要自定義字段添加到.gitconfig
文件,使用此命令:
git config --global user.customfield
例如:
$ git config --global user.customfield test
$ git config --global user.customfield
test
此外,避免_
「
git config --global user.customfield <value>
然後,您可以用檢索s在自定義字段名稱中。 Git不解析它們:
$ git config user.custom_field test
error: invalid key: user.custom_field
謝謝,但這是在本地檢索它。我需要在服務器上掛鉤 – Alex 2012-07-06 14:44:20
你想完成什麼?當你說「使用git的內置命令獲取名稱和電子郵件很容易」時,你指的是什麼? – Christopher 2012-07-06 14:46:53
如果您在本地討論它的.gitconfig文件,但您嘗試訪問服務器端的數據,那麼您運氣不好。但是,您可以強制執行提交消息模板:http://stackoverflow.com/a/3967136/877115然後拒絕不提供'custom_field'服務器端的提交:http://stackoverflow.com/a/11314667/877115 – Christopher 2012-07-06 14:59:39