push declined due to email privacy restrictions 解决方法

38 阅读1分钟

push declined due to email privacy restrictions 解决方法

将本地仓库 push 到 github 报错:

异常信息:

! [remote rejected] main -> main (push declined due to email privacy restrictions)

异常原因:配置 git 时设置了作者邮箱信息,触发了Github 隐私保护设置: Block command line pushes that expose my email

解决方法:

1、关闭 setttings => Emails => Block command line pushes that expose my email 这个选项【不推荐】

2、更改 git 配置的邮件地址

1、使用命令查看当前的全局用户 Email: git config --global user.email

2、 setttings => Email => keep my Email private 选项下的 Email; 格式是:id+username@users.noreply.github.com

3、重新设置全局用户 Email: git config --global user.email “GitHub 给的推荐 Email”

4、重新提交 git push