[Git] 解决Push失败: Push Failed:push declined due to email privacy restrictions

64 阅读1分钟

一、问题描述

将项目更新内容Push到远程仓库上时,显示提交失败:

image.png

二、问题分析

这是由于Github出于隐私性考虑在执行Git Push时,将不再需要你的真实邮箱,而是在Github Email settings中提供了一个掩码邮箱地址,格式为

{ID}+{username}@users.noreply.github.com

比如我的是:

image.png

三、解决方案

1.修改当前的git email

git email地址修改为刚刚那个地址,注意--global修饰符

git config --global user.email {ID}+{username}@users.noreply.github.com 

2. 重置上一次提交

在你要提交的项目工作目录下打开 git bash,将重置内容附加到上一次提交:

git commit --amend --reset-author

四、问题解决

image.png