没有电子邮件的 Git 提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7372970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:59:07  来源:igfitidea点击:

Git commit with no email

git

提问by neodelphi

I'am currently converting a svn repository into a git one. As I proceed manually, I regularly change the user.name and user.email to set the author of the commit. Everything seems to work fine, but now I have to commit something from a user which has no email address. I removed email property from .gitconfig file and tried, but then in git log, email field shows user_login@user_login.(none). Is it possible to set no email and prevent git guessing one ?

我目前正在将 svn 存储库转换为 git 存储库。当我手动进行时,我会定期更改 user.name 和 user.email 以设置提交的作者。一切似乎都正常,但现在我必须从没有电子邮件地址的用户那里提交一些内容。我从 .gitconfig 文件中删除了 email 属性并尝试了,但是在 git log 中,电子邮件字段显示user_login@user_login.(none). 是否可以不设置电子邮件并防止 git 猜测一个?

采纳答案by CB Bailey

I think that you can only do this with an explicit author specification:

我认为您只能使用明确的作者规范来做到这一点:

git commit --author "Snail Mail <>"

You need the angle brackets so that git knows that you really are passing an empty email address.

您需要尖括号,以便 git 知道您确实在传递一个空的电子邮件地址。

回答by Sparhawk

Similar to neodelphi's comment, you can set this for all commits with

类似于 neodelphi 的comment,您可以为所有提交设置它

git config --global user.name 'Snail Mail'
git config --global user.email '<>'

(You can use quotes instead of escaping.) To set this for the current project only, remove the --globaloption only. i.e.

(您可以使用引号代替转义。)要仅为当前项目设置此项,请仅删除该--global选项。IE

git config user.name 'Snail Mail'
git config user.email '<>'

回答by practechal

the accepted answer doesn't work on some git versions (including, but not limited to mine (@Szczepan Ho?yszewski@xiaodai) )

接受的答案不适用于某些 git 版本(包括但不限于我的(@Szczepan Ho?yszewski @xiaodai))

this answerworked for me

这个答案对我有用