您无法推送“[email protected]”的提交。您只能推送使用您自己验证的电子邮件之一提交的提交

问题描述 投票:0回答:2

我无法将我的提交推送到 gitlab 中的远程存储库。我通过运行以下命令设置了全局 user.name 和 user.email:

git config --global user.email "[email protected]"
git config --global user.name "serena"
git commit --amend --reset-author --no-edit

当我跑步时

git config --global -l
并且。
git config -l
,它确实显示了我的凭据。

我还尝试删除本地存储库并重新下载。没有什么对我有用。有人有任何建议来解决这个问题吗?

添加完整的回溯:

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 419 bytes | 419.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0
remote: GitLab: You cannot push commits for '[email protected]'. You can only push commits that were committed with one of your own verified emails.
To https://gitlab.beno.ai/example.git
 ! [remote rejected] TIDTA-94 -> TIDTA-94 (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.beno.ai/example.git'
git gitlab git-push
2个回答
0
投票

我知道现在回答已经太晚了,但这个问题背后的真正原因是

提交是通过未经授权的电子邮件完成的,当您推送时,GIT会检查已经提交的GIT配置,而不是您当时计算机上的配置。 这就是为什么当您在提交后更改 git config 中的电子邮件时,它仍然会给出相同的错误。

尝试以下两种解决方案之一:

  • 请参阅 Stack Exchange 上的此解决方案,该解决方案会重置提交的作者。
  • 取消提交最后一次提交(导致问题的提交),然后更改 git 用户和电子邮件,然后再次提交并推送。 使用 git 客户端程序(例如(GitHub Desktop、源代码树等))这应该很容易

在 GitHub 桌面:

1- 转到History,您将看到您最近的提交是第一个,右键单击它,然后取消提交。 完成此操作后,更改应再次出现在“changes”部分中。

2- 转到左上角的文件 --> 选项 --> Git,插入您的凭据并点击保存。

3-提交并推送。


-1
投票

我能够使用 SSH 克隆的存储库来推送提交。我之前使用 HTTPS 克隆了远程存储库。

© www.soinside.com 2019 - 2024. All rights reserved.