防止git丢失时自动生成用户电子邮件 [英] Prevent git from automatically generating user email if missing
问题描述
是否有一种方法可以全局配置git
,以使其不自动生成用户的电子邮件(如果未设置该电子邮件并改为中止提交)?
Is there a way to globally configure git
to not automatically generate user's email, if none is set and abort the commit instead?
$ git commit -m "test"
[master (root-commit) 71c3e2e] test
Committer: unknown <my.user@my.very.own.hostname>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
如果提交者不足够仔细地检查git
警告,则可能导致严重的隐私泄漏.
This can cause serious privacy leaks if the committer is not careful enough to check git
warnings.
推荐答案
设置git config --global user.useConfigOnly true
user.useConfigOnly
user.useConfigOnly
指示Git避免尝试猜测user.email和user.name的默认值,而是仅从 配置.例如,如果您有多个电子邮件地址,并且 想要为每个存储库使用不同的存储库,然后使用此存储库 配置选项在全局配置中与true一起设置为true 名称,Git会提示您设置电子邮件,然后再进行新的提交 在新克隆的存储库中.默认为false.
Instruct Git to avoid trying to guess defaults for user.email and user.name, and instead retrieve the values only from the configuration. For example, if you have multiple email addresses and would like to use a different one for each repository, then with this configuration option set to true in the global config along with a name, Git will prompt you to set up an email before making new commits in a newly cloned repository. Defaults to false.
这篇关于防止git丢失时自动生成用户电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!