git 提交者电子邮件地址在 IntelliJ 中不匹配,即使将其更改为更正

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31652094/
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-09 03:24:39  来源:igfitidea点击:

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

gitintellij-ideagerrit

提问by Tadas Davidsonas

When I try to push my commits from git repository to gerrit remote repository from Linux environment in IntelliJ idea I get the following error:

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

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

Even if I changed the settings to the correct ones for git and gerrit (I can see that at: git config -lfrom console), it still picks the old "wrong" email.

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

What could be wrong?

可能有什么问题?

回答by Frederic Henri

you need to reconfigure your email

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

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

git commit --amendupdates your last commits

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

回答by Dulith De Costa

You can set the username and email for GITintegration as follows. This will help you to overcome the mismatch issue.

您可以按如下方式设置用于GIT集成的用户名和电子邮件。这将帮助您克服不匹配问题。

Go to your project where git is initialized.

转到初始化git 的项目。

Then enable the hidden folders and find ".git" and go inside the folder.

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

Find the file called "config" and add below code and save.

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

[user]
      name = username
      email = [email protected]

Enter your correct username and email accordingly. This will be picked permanently unless you go and change it.

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

回答by NavsTrend

I encountered the same issue, when trying to push from Git to Gerrit. The possible conflict is because, the code got cloned from the login id of git and when trying to push, it is being cross-verified with Gerrit Credentials. These 2 being different, the conflict is thrown. Resolved it by running these 2 commands:

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

回答by milegrin

I experienced the same error when our corporate email address changed and for me was easily fixed with :

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

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"

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

Run in the root of the git repo.

在 git repo 的根目录中运行。

Based on : https://help.github.com/en/github/using-git/changing-author-info

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

I also edited the repo's .git/config to add the user stanza :

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

[user]
  name = Your Correct Name
  email = [email protected]

Then

然后

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

PS: This is on a Gerrit Server

PS:这是在 Gerrit 服务器上

回答by Menelaos Kotsollaris

As Frédéric Henri mentions, you have to configure properly your email through git config user.emailor directly through editing the \.git\configfile in your repo folder.

正如Frédéric Henri 提到的,您必须通过git config user.email或直接通过编辑\.git\configrepo 文件夹中的文件来正确配置您的电子邮件。

One important thing that might go unnoticed is the fact that you have to update all the previous commits that contain the fault email. Git will complain about the email pattern but it won't mention which commit is the problematic one.

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

You can use git rebaseor git resetand then once you commit you can push successfully!

你可以使用git rebaseorgit reset然后一旦你提交你就可以成功推送!