Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

git - Error "Your push would publish a private email address"

I'm very new to GitHub/VCS.

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

    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 Stack?Exchange, but no cigar. How can I solve this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

  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 private checkbox. 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 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"
      
  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
    

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...