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

5

38

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:

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 -l from console), it still picks the old "wrong" email.

What could be wrong?

Munt answered 27/7, 2015 at 11:38 Comment(1)
Possible duplicate of Git push error: does not match your user accountRudolph
C
117

you need to reconfigure your email

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

git commit --amend updates your last commits

Caudell answered 27/7, 2015 at 11:42 Comment(2)
Looks like it helps for some files but not for all the committed files so I can't push still.Munt
if you have older commits that do not have the right author, you'll need to update those, run git log to check which commits do not have correct author then run git rebase -i <commit you want to amend>^ so you can do again git commit --amend --author "New Author Name <[email protected]>"(or --reset-author) and continue rebasing. once you have all commit fixed you should be able to pushCaudell
P
3

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

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.

You can use git rebase or git reset and then once you commit you can push successfully!

Phraseology answered 12/4, 2018 at 18:15 Comment(1)
git reset worked for me. Thanks.Designedly
B
3

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:

Bowling answered 16/10, 2019 at 5:23 Comment(0)
I
2

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

Go to your project where git is initialized.

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

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

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

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

Intercessor answered 28/10, 2018 at 16:27 Comment(0)
M
2

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.

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

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

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

Then

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

PS: This is on a Gerrit Server

Monagan answered 29/5, 2020 at 16:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.