我对GitHub/VCS很陌生。
当我尝试在GitHub上分享我的项目时,我得到了以下错误消息。
Can't finish GitHub sharing process
Successfully created project 'myproject' on GitHub, but initial push failed:
remote: error: GH007: Your push would publish a private email address.
failed to push some refs to 'https://github.com/me/myproject.git'
我用谷歌搜索了错误信息,没有结果。我还搜索了Stack Exchange,但一无所获。我该如何解决这个问题?
当启用“阻止命令行推送暴露我的电子邮件”功能时,您还需要配置Git以使用您的无回复电子邮件地址。别担心——这不会影响你的贡献图。所有提交仍将与您的帐户相关联。
Open Terminal.
Change the current working directory to the local repository where you want to configure the email address that you associate with your Git commits.
Find your GitHub noreply address in your GitHub's Personal Settings → Emails. It's mentioned in the description of the Keep my email address private checkbox. Usually, it starts with a unique identifier, plus your username.
Set an email address in Git. Use your GitHub-provided no-reply email address.
Setting your email address for every repository on your computer
git config --global user.email "{ID}+{username}@users.noreply.github.com"
Setting your email address for a single repository
git config user.email "{ID}+{username}@users.noreply.github.com"
Reset the author information on your last commit:
git commit --amend --reset-author
If you have multiple commits with your private e-mail address, see this answer.
Now you can push the commit with the noreply e-mail address, and future commits will have the noreply e-mail address as well.
git push
一旦你配置了Git,提交将使用你的备用“不回复”电子邮件地址,任何不这样做的推送都将被拒绝。
有一个解决方案,w/o暴露你的电子邮件。错误发生是因为你在git配置中配置了自己的电子邮件地址——(global|system|local) user.email。
如果相同的电子邮件是你的Github电子邮件,你已经选择了使你的电子邮件私有的选项,这个错误会被git标记。
有帮助的是,Github为您提供了一个无回复的电子邮件地址,您可以使用命令行操作。只要检查你的电子邮件设置在你的Github个人资料。
您可以简单地删除或撤销使用user.name完成的提交,在再次提交更改之前,设置另一个电子邮件为
Git配置——(全局|系统|本地)用户。电子邮件" < no-reply-email-here >”。
现在,当您尝试将更改推到远程回购时,错误应该消失了。