我遇到了这个奇怪的问题,我用我的凭据 ( my_correct@email.adress
)克隆了一个存储库。但我无法推送更改,因为我总是收到此消息:
GitLab: You cannot push commits for 'my_wrong@email.adress' . You can only push commits that were committed with one of your own verified emails.
Run Code Online (Sandbox Code Playgroud)
问题是,当我检查全局和存储库用户时,我发现它是my_correct@email.adress
:
全球(以下确认我的正确地址):
git git config --global user.email
git config --global user.name
Run Code Online (Sandbox Code Playgroud)
存储库(下面确认我的正确地址):
git git config user.email
git config user.name
Run Code Online (Sandbox Code Playgroud)
我该怎么办,这个神秘的谜团背后的原因是什么?
小智 16
就我而言,GitLab 上的项目存在提交者限制。“用户只能将使用自己经过验证的电子邮件之一提交的提交推送到此存储库。” 由于我也在我的机器上配置了 SSH,所以我的用户电子邮件在 git 全局文件中使用我的机器地址进行了更新,因此远程不允许推送。
您可以在-gitlab->设置->存储库->推送规则中找到它;只需禁用此提交限制即可。
git commit --amend --reset-author --no-edit
仅在最后一次提交中更改作者,如果您有多个提交,您仍然无法推送。
使用 检查它git log
,并使用不正确的作者重置每个提交并再次提交。
小智 5
我能够使用这个 git 命令解决同样的问题:
git commit --amend --reset-author --no-edit
我最初尝试使用错误的电子邮件提交,但即使在设置 user.name 和 user.email 之后 git config --global
,我仍然收到相同的“您无法推送...”错误。
解决方案是在 git 中重置作者 - 然后推送被 Gitlab 接受。
供参考:https : //github.com/git-tips/tips#revert-undo-a-commit-by-creating-a-new-commit
归档时间: |
|
查看次数: |
13416 次 |
最近记录: |