GitHub報錯:error: GH007: Your push would publish a private email address.

0

天津11选5走势图分析 www.lixcgb.com.cn 在GitHub的隱私設置中勾選了Block command line pushes that expose my email后,再次提交的Git項目中如果提交暴露私人郵箱地址的commit時會報錯

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: //github.com/settings/emails
To github.com:xxxx/xxxx.git
 ! [remote rejected] master -> master (push declined due to email privacy restrictions)
error: failed to push some refs to '[email protected]:xxxx/xxxx.git'

網上搜索了一下,大多提供的解決方案都是取消Keep my email address private,這顯然違背了GitHub提供這個功能的初衷,并且會公開你的私人郵箱
真正的解決方案應該是修改Git中的郵箱地址為GitHub提供的匿名郵箱才對

# 修改全局郵件地址
git config --global user.email "用戶名@users.noreply.github.com"
git config user.email "用戶名@users.noreply.github.com"
# 重置 commit 的作者信息
git commit --amend --reset-author
# 再次提交
git push

發表評論

您的郵箱不會公開,當您的評論有新的回復時,會通過您填寫的郵箱向您發送評論內容。 必填字段 *

為何看不到我發布的評論?

正在提交, 請稍候...