我想提交一些变化为不同的用户,但我没有一个有效的电子邮件地址,下面的命令不是为我工作:
git commit --author="john doe" -m "some fix"
fatal: No existing author found with 'john doe'
试图只用一个电子邮件地址,提交时,我有同样的问题
git commit --author="john@doe.com" -m "some fix"
fatal: No existing author found with 'john@doe.com'
在git的手册页commit命令它说我可以使用
standard A U Thor <author@example.com> format
对于--author选项。
凡被定义这种格式? 什么是一个和U代表什么? 我如何提交针对只包含用户名或只用电子邮件不同的用户?
必需的最少笔者格式,暗示在这个SO回答 ,是
Name <email>
在你的情况,这意味着你想写
git commit --author="Name <email>" -m "whatever"
每威廉D'Haeseleer的评论,如果你没有一个电子邮件地址,你可以使用<>
git commit --author="Name <>" -m "whatever"
作为对书面git commit
手册页你联系,如果提供任何低于该值,它被用来作为一个搜索令牌通过先前提交的搜索,寻找该作者其他的提交。
具体格式为:
git commit --author="John Doe <john@doe.com>" -m "Impersonation is evil."
该
标准 AU托尔<author@example.com>格式
似乎跟着来定义:(据我所知,绝对没有保修)
AU托尔= 所需的用户名
- 角色的分离可能表明有空格,它也可以类似的缩写。
- 用户名已被后跟1个空间,多余的空格将被截断
<author@example.com> = 可选的电子邮件地址
- 必须始终<>符号之间。
- 电子邮件地址格式不验证,你几乎可以输入任何你想要的
- 可选,您可以通过使用明确省略此<>
如果不使用这个确切的语法,git会通过现有提交搜索和使用的第一次提交包含您提供的字符串。
例子:
只有用户名
明确忽略的电子邮件地址:
git commit --author="John Doe <>" -m "Impersonation is evil."
只有电子邮件
从技术上讲,这是不可能的。 但是,您可以输入电子邮件地址作为用户名,并明确省略的电子邮件地址。 这似乎并不像它的非常有用的。 我相信这会令更多的意义,从电子邮件地址提取用户名,然后使用它作为用户名。 但是,如果你有:
git commit --author="john@doe.com <>" -m "Impersonation is evil."
尝试将库从善变转向Git的时候我跑了这一点。 我对msysgit 1.7.10测试的命令。
格式
A U Thor <author@example.com>
只是意味着你应该指定
FirstName MiddleName LastName <email@example.com>
貌似中,姓氏是可选的(也许电子邮件之前的部分不具有严格的格式在所有)。 尝试,例如,这样的:
git commit --author="John <john@doe.com>" -m "some fix"
由于文档说:
--author=<author>
Override the commit author. Specify an explicit author using the standard
A U Thor <author@example.com> format. Otherwise <author> is assumed to
be a pattern and is used to search for an existing commit by that author
(i.e. rev-list --all -i --author=<author>); the commit author is then copied
from the first such commit found.
如果不使用这种格式,git的零食提供的字符串作为模式,并试图找到其他提交的作者之间的匹配名称。
只是补充:
git的承诺--author = “john@doe.com” -m “模拟是邪恶的。”
在某些情况下,提交仍然失败,并告诉您以下信息:
***请告诉我你是谁。
跑
混帐配置--global user.email“you@example.com”混帐配置--global user.name“你的名字”
设置您的帐户的默认身份。 忽略--global设置身份只有在这个仓库。
致命:无法自动检测的电子邮件地址(有XXXX)
所以,只要运行“混帐配置”,然后“git的承诺”
从终端运行这两个命令来设置用户的电子邮件和名称
git config --global user.email "you@example.com"
git config --global user.name "your name"
如果您正致力于Github上,你并不需要一个真实的电子邮件,您可以使用<username>@users.noreply.github.com
无论使用Github上与否,你可能首先要改变你的提交者的详细信息(在Windows上使用SET GIT_...
)
GIT_COMMITTER_NAME='username'
GIT_COMMITTER_EMAIL='username@users.noreply.github.com'
然后设置作者
git commit --author="username <username@users.noreply.github.com>"
https://help.github.com/articles/keeping-your-email-address-private