Github启用email保护

开启github email保护

github settings中可以开启 Keep my email addresses privateBlock command line pushes that expose my email 两个选项

如果此时使用使用命令push代码时会收到以下报错:

remote: error: GH007: Your push would publish a private email address.
remote: You can make your email public or disable this protection by visiting:
remote: http://github.com/settings/emails

解决方法如下

  • github settings中找到GitHub noreply address

  • 修改git仓库email地址

    # 修改当前仓库
    git config user.email "{ID}+{username}@users.noreply.github.com"
    
    # 修改所有仓库
    git config --global user.email "{ID}+{username}@users.noreply.github.com"
    
  • 重置最后一次提交中的作者信息

    git commit --amend --reset-author --no-edit
    
  • 最后正常提交即可

    git push
    

 Share!

 
comments powered by Disqus