提交者电子邮件地址在 IntelliJ 中不匹配,甚至将其更改为更正一个

Commiter email address does not match in IntelliJ even changing it to correct one

当我尝试在 IntelliJ idea 中将我的提交从 git 存储库推送到来自 Linux 环境的 gerrit 远程存储库时,我收到以下错误:

remote: ERROR:  committer email address ***** [K
remote: ERROR:  does not match your user account.[K

即使我将 git 和 gerrit 的设置更改为正确的设置(我可以在 git config -l 从控制台看到),它仍然会选择旧的 "wrong" 电子邮件.

有什么问题吗?

您需要重新配置您的电子邮件

$ git config user.email <your email>
$ git commit --amend --reset-author

git commit --amend 更新您的最后一次提交

一样,您必须通过 git config user.email 或直接通过编辑 repo 文件夹中的 \.git\config 文件来正确配置您的电子邮件。

一件可能被忽视的重要事情是 您必须更新所有包含故障电子邮件的先前提交。 Git 会抱怨电子邮件模式,但不会提及哪个提交有问题。

您可以使用git rebase or git reset,然后一旦提交就可以成功推送!

您可以为 GIT 集成设置用户名和电子邮件,如下所示。这将帮助您克服不匹配问题。

转到 git 已 初始化 的项目。

然后启用隐藏文件夹并找到“.git”并进入文件夹。

找到名为“config”的文件并添加以下代码并保存。

[user]
      name = username
      email = username@domaim.com

输入正确的用户名和相应的电子邮件。除非您去更改它,否则它将被永久选中。

我在尝试从 Git 推送到 Gerrit 时遇到了同样的问题。可能的冲突是因为,代码是从 git 的登录 ID 克隆的,并且在尝试推送时,它正在与 Gerrit 凭据进行交叉验证。这两个不同,就会引发冲突。 通过 运行 这 2 个命令解决了它:

  • git 配置 --global user.email "email@example.com"
  • git commit --amend --author ="Author Name <'email@address.com>"

当我们的公司电子邮件地址更改时,我遇到了同样的错误,对我来说很容易修复:

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

运行 在 git 存储库的根目录中。

基于: https://help.github.com/en/github/using-git/changing-author-info

我还编辑了 repo 的 .git/config 以添加用户节 :

[user]
  name = Your Correct Name
  email = your-correct-email@example.com

然后

git commit --amend --reset-author
git push

PS:这是在 Gerrit 服务器上