git 您的推送会发布私人电子邮件地址错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43863522/
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-09 04:57:48  来源:igfitidea点击:

Your push would publish a private email address error

gitgithub

提问by user156060

I'm very new to Github/VCS.

我对 Github/VCS 很陌生。

When I try to share my project on Github, I get the following error message.

当我尝试在 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'

I've googled the error message, and got no hits. I've also searched stackexchange, but no cigar. Any ideas on how to solve this issue?

我在谷歌上搜索了错误消息,但没有任何结果。我也搜索过stackexchange,但没有雪茄。关于如何解决这个问题的任何想法?

采纳答案by sofia-fernandez

I experienced the same error: GH007message as well, and used the following to resolve the issue.

我也遇到了同样的error: GH007消息,并使用以下方法解决了问题。

  1. Go to https://help.github.com/articles/setting-your-email-in-git/.
  2. Follow the Setting your email address for every repository on your computer.
  3. Open your GitHub account, and go to Settings> Emails.
  4. Select the Keep my email address privatecheck box.
  5. Unselect the Block command line pushes that expose my emailcheck box.
  1. 转到https://help.github.com/articles/setting-your-email-in-git/
  2. 按照为计算机上的每个存储库设置电子邮件地址
  3. 打开您的 GitHub 帐户,然后转到设置>电子邮件
  4. 选中将我的电子邮件地址保密复选框。
  5. 取消选中公开我的电子邮件阻止命令行推送复选框。

This may expose your email address though.

不过,这可能会暴露您的电子邮件地址。

回答by Winfried

When enabling the “Block command line pushes that expose my email” feature, you'll also want to configure Git to use your no-reply email address. Don't worry—this won't affect your contribution graph. All commits will still be associated with your account.

启用“阻止暴露我的电子邮件的命令行推送”功能时,您还需要将 Git 配置为使用您的无回复电子邮件地址。别担心——这不会影响你的贡献图。所有提交仍将与您的帐户相关联。

  1. Open Terminal.

  2. Change the current working directory to the local repository where you want to configure the email address that you associate with your Git commits.

  3. Find your GitHub noreply address in your GitHub's Personal Settings → Emails. It's mentioned in the description of the Keep my email address privatecheckbox. Usually, it starts with a unique identifier, plus your username.

  4. Set an email address in Git. Use your GitHub-provided no-reply email address.

    • Setting your email address for everyrepository on your computer

      git config --global user.email "{ID}+{username}@users.noreply.github.com"
      
    • Setting your email address for a singlerepository

      git config user.email "{ID}+{username}@users.noreply.github.com"
      
  5. 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.

  6. 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
    
  1. 打开终端。

  2. 将当前工作目录更改为要配置与 Git 提交关联的电子邮件地址的本地存储库。

  3. 在 GitHub 的Personal Settings → Emails 中找到您的 GitHub noreply 地址。在“保持我的电子邮件地址私密”复选框的描述中提到了这一点。通常,它以唯一标识符开头,加上您的用户名。

  4. 在 Git 中设置电子邮件地址。使用 GitHub 提供的无回复电子邮件地址。

    • 为计算机上的每个存储库设置电子邮件地址

      git config --global user.email "{ID}+{username}@users.noreply.github.com"
      
    • 单个存储库设置您的电子邮件地址

      git config user.email "{ID}+{username}@users.noreply.github.com"
      
  5. 重置上次提交的作者信息:

    git commit --amend --reset-author
    

    如果您的私人电子邮件地址有多个提交,请参阅此答案

  6. 现在您可以使用 noreply 电子邮件地址推送提交,未来的提交也将具有 noreply 电子邮件地址。

    git push
    

Once you configure Git, commits will use your alternate “noreply” email address, and any pushes that don't will be rejected.

一旦您配置了 Git,提交将使用您的备用“noreply”电子邮件地址,任何不这样做的推送都将被拒绝。

回答by Burhan Khalid

You have probably enabled (or it is enabled now by default) the email privacy feature of github.

您可能已启用(或现在默认启用)github 的电子邮件隐私功能。

It is detailed on this page at github help.

在 github help 的这个页面上有详细说明。

In short, there is a toggle that you can enable (which is enabled on your account) that prevents any push where the user is your actual email address. You can use an anonymized address instead (or choose to disable the feature).

简而言之,您可以启用一个切换(在您的帐户上启用),以防止用户是您的实际电子邮件地址的任何推送。您可以改用匿名地址(或选择禁用该功能)。

Details for both options are available at the same page.

同一页面上提供了这两个选项的详细信息。

回答by Peter Doherty

I had the same issue. My solutionis in the picture below:

我遇到过同样的问题。我的解决方案如下图所示:

GitHub Settings

GitHub 设置