git push报错 emote: error: GH007

本文详细解析了在GitHub上因私有邮箱设置导致的Push错误(GH007),并提供了解决方案,包括检查.git/config文件中的user.name和user.email设置,以及如何通过修改这些设置来避免公开个人邮箱。

报错信息:
Pushing to https://github.com/***.git POST git-receive-pack (1288 bytes) 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 To https://github.com/***.git ! [remote rejected] master -> master (push declined due to email privacy restrictions) error: failed to push some refs to 'https://github.com/***.git'

出现报错的场景
由于使用公司电脑,设置了global的全局git账号。我在自己的github仓库,修改了name和email,然后就push不了了。

解决方法:
网上还有一种方法:
Open your GitHub account, and go to Settings > Emails.
Select the Keep my email address private check box.
就是将email的私有设置为公开,可我就是不想公开,便找到如下解决方案。

  1. 如果也是配置了name和email,则先确认仓库的.git 中的config的是否正确:
    git config user.name "{name}" 【就是github中Public profile下的Name】
    git config user.email "{username}@users.noreply.github.com"【就是github中点击头像,Signed in as 后面的那个名字,也是生成代码路径中标识的那个名字】
    其实,这个用户名和邮箱,也是第一次检出代码时那个。

  2. 跳出后.git文件夹,在仓库文件夹下,输入命令行:
    git commit --amend --reset-author
    esc
    :wq
    然后使用sourceTree就push成功了。

解决方法参考:
https://stackoverflow.com/questions/43863522/your-push-would-publish-a-private-email-address-error

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值