如果我运行git config --global user.email
我会得到:16969914+jamesray1@users.noreply.github.com
.
然后,如果我在我的 Github 电子邮件设置中勾选了"阻止暴露我的电子邮件的命令行推送"git push
运行,它不起作用,与error: GH007: Your push would publish a private email address.
在输出中。 我无法将此电子邮件地址添加到 Github,因为它已经添加(如果我尝试,我会收到一个错误通知我)。 如果我取消选中"阻止暴露我的电子邮件的命令行推送",那么git push
工作。 我读过这些文章:
- https://help.github.com/articles/setting-your-commit-email-address-in-git/
- https://help.github.com/articles/about-commit-email-addresses/
- https://help.github.com/articles/setting-your-commit-email-address-on-github/ -
我向Github支持发送了一条消息,但如果有人有任何想法,请随时回答。
我怀疑在您更改设置之前,您已经进行了提及真实电子邮件的提交。您现在应该修改本地提交,以便它们使用 github 的代理电子邮件
基于这个答案,它会像(我没有测试它!
$ git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "REAL_EMAIL" ];
then GIT_AUTHOR_EMAIL="PROXY_EMAIL";
fi;
if [ "$GIT_COMMITTER_EMAIL" = "REAL_EMAIL" ];
then GIT_COMMITTER_EMAIL="PROXY_EMAIL";
fi;
git commit-tree "$@" ' -- @{u}..
这假设您不想更改姓名,只想更改电子邮件。 我认为选择器@{u}..
应该选择那些提交 你会推。