Git 推送错误:与您的用户帐户不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40650926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:26:27  来源:igfitidea点击:

Git push error: does not match your user account

gitgerrit

提问by LayaCCC

I executed the following commands:

我执行了以下命令:

git pull <partner_remote> <partner_branch>
git config user.email <my_email>
git config user.name <my_name>
git commit --amend --reset-author
git push <my_remote> HEAD:refs/for/<my_branch>

But I got the following error after the "git push":

但是在“git push”之后我得到了以下错误:

remote: ERROR:  In commit b6b74fff7850c4b61a5535519959b1ab58ca6fa9
remote: ERROR:  committer email address aaa@aaa
remote: ERROR:  does not match your user account.
remote: ERROR:
remote: ERROR:  The following addresses are currently registered:
remote: ERROR:    bbb@bbb
remote: ERROR:
remote: ERROR:  To register an email address, please visit:
remote: ERROR:  http://xxxxxxxx

I have no idea how to fix it.

我不知道如何解决它。

回答by The Godfather

In addition, one may get the same error when you're trying to commit other people's changes. It's a pretty common use case in my team when there is a commit in review from John, but John went to vacation\sick leave\day off and some feedback appeared. So if commit has to me merged ASAP, it requires some changes. Gerrit allows you to checkout anyone's commit, make a change and upload it as a new patch set. The original author (John) will be still "Author", but you will be "Commiter".

此外,当您尝试提交其他人的更改时,可能会遇到相同的错误。这是我团队中一个非常常见的用例,当 John 提交时,但 John 去休假\病假\休息日并且出现了一些反馈。因此,如果提交必须尽快合并给我,则需要进行一些更改。Gerrit 允许您检查任何人的提交,进行更改并将其作为新补丁集上传。原作者 (John) 仍将是“作者”,但您将是“提交者”。

It was just a brief description of the case, now back to the issue. In my team our Gerrit configuration is set up so "Submitter" by default doesn't have Forge Author\Forge Committerpermissions, so you'll get the very same error as mentioned in the question when trying to upload a new patch set.

以上只是对案例的简单描述,现在回到正题。在我的团队中,我们的 Gerrit 配置设置为默认情况下“提交者”没有Forge Author\Forge Committer权限,因此在尝试上传新补丁集时,您将遇到与问题中提到的完全相同的错误。

The solution is to request higher role in your gerrit project (Maintainer, Developer or Administrator)

解决方案是在您的 gerrit 项目中请求更高的角色(维护者、开发者或管理员)

As an alternative, one can force override author of the commit:

作为替代方案,可以强制覆盖提交的作者:

git commit --amend --reset-author

回答by Marcelo ávila de Oliveira

If I understood correctly, (aaa@aaa) is different from bbb@bbb e-mail which is registered in Gerrit, right? So... check if aaa@aaa is your correct e-mail and register it in Gerrit:

如果我理解正确,(aaa@aaa) 和在 Gerrit 中注册的 bbb@bbb 电子邮件不同,对吗?所以...检查 aaa@aaa 是否是您正确的电子邮件并在 Gerrit 中注册:

  1. Go to Gerrit
  2. Click on "YOUR NAME" (up right)
  3. Click on "Settings"
  4. Click on "Contact Information"
  5. Click on "Register New Email..."
  6. Fill the field with aaa@aaa and click on "Register"
  1. 去格里特
  2. 点击“你的名字”(右上角)
  3. 点击“设置”
  4. 点击“联系方式”
  5. 单击“注册新电子邮件...”
  6. 用 aaa@aaa 填写该字段,然后单击“注册”

You'll receive a "[Gerrit Code Review] Email Verification" e-mail, follow the instructions to add the aaa@aaa email address to your user account.

您将收到一封“[Gerrit Code Review] 电子邮件验证”电子邮件,请按照说明将 aaa@aaa 电子邮件地址添加到您的用户帐户。

回答by Bhargava GM

You can run these commands:

您可以运行以下命令:

git config --global user.name "Your Name"
git config --global user.email [email protected]

Then run this to edit the commit to reset the author:

然后运行它来编辑提交以重置作者:

git commit --amend --reset-author

回答by Lokkesh

This is due to git credential-managerstoring the previous login Credential.

这是由于git credential-manager存储了以前的登录凭据。

Here is the Fix, Just Execute :

这是修复,只需执行:

git credential-manager clear <gerrit url>

eg : git credential-manager clear https://mygerrit.com

例如:git credential-manager clear https://mygerrit.com

If you Push or clone again it will prompt for Username and Password

如果你再次推送或克隆它会提示输入用户名和密码

回答by Jaysonsu

Go Gerrit -> Settings -> HTTP Credentials,follow guide step to finished below option: Obtain password (opens in a new tab)

转到 Gerrit -> 设置 -> HTTP 凭据,按照指南步骤完成以下选项:获取密码(在新选项卡中打开)