我可以让git配置不提供我的电子邮件值吗?

huangapple go评论98阅读模式
英文:

Can I make git config not supply the value of my email?

问题

如果我运行 git config --get user.email,它会显示我的当前电子邮件地址。是否可以配置git,使我可以为提交设置一个电子邮件值,但在使用 --get 开关时不会显示它?

或者,我可以设置一个环境变量,使得 git config --get user.email 不会返回任何内容,但我的提交仍然会带有我的电子邮件?或者我的提交可以使用除了我的电子邮件地址之外的唯一标识符吗?

我简要查看了git-config文档页面,寻找关于 --get 和 "email" 的提及。环境变量看起来很有前景,但我还没有尝试过。

相关问题:https://stackoverflow.com/questions/28912322/why-does-git-ask-for-users-email-address

英文:

If I run git config --get user.email, it displays my current email address. Is it possible to configure git such that I can set a value of the email for a commit, but it won't display it with the --get switch?

Alternatively, can I just set an environment variable such that git config --get user.email won't get anything, but my commits will still have my email? Or can my commits use a unique identifier other than my email address?

I had a brief look at the git-config documentation page, looking for mentions of --get and "email". The environment variables look promising but I haven't tried them.

Related question: https://stackoverflow.com/questions/28912322/why-does-git-ask-for-users-email-address

答案1

得分: 1

你不能使git config无法获取已使用的电子邮件,因为git config使用与Git相同的机制。但是,您可以避免设置(或取消设置)user.email,并使用环境变量EMAIL,如果未设置user.email和Git特定的环境变量,则会设置该值。我这样做效果很好。

完整的详细信息在git-commit手册页面中。

英文:

You cannot make git config unable to fetch the email that's used, because git config uses the same machinery as Git uses. However, you can avoid setting (or unset) user.email and use the environment variable EMAIL, which will set the value if user.email and the Git-specific environment variables are not set. I do this and it works great.

The full details are in the git-commit manual page.

huangapple
  • 本文由 发表于 2023年8月10日 18:24:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76874847.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定