push declined due to email privacy restrictions (GH007 error code) 解决方法
将本地仓库 push 到 github 报错:
异常信息:
! [remote rejected] master -> master (push declined due to email privacy restrictions)
异常原因:配置 git 时设置了作者邮箱信息,触发了Github 隐私保护设置: Block command line pushes that expose my email
解决方法:
关闭 Block command line pushes that expose my email 这个选项:
很多人选择关掉 GitHub 中 Email 设置选项 Block command line pushes that expose my email ;很粗暴但是不推荐。
个人推荐:
更改 git 配置的邮件地址: 如果不想关闭上面的设置,可以通过修改 Email 来解决:
1、使用命令查看当前的全局用户 Email: git config --global user.email
2、找到Github 推荐Email: 在 settting --> Email --> keep my Email private 选项下的 Email; 格式是:id+username@users.noreply.github.com
3、重新设置全局用户 Email: git config --global user.email “GitHub 给的推荐 Email”
4、重置上次提交的作者信息 git commit --amend --reset-author
输入命令后,进入vi模式( git 默认的编辑器);
5、重新提交 git push