Git push error: does not match your user account
Asked Answered
S

9

13

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":

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.

Sapotaceous answered 17/11, 2016 at 9:20 Comment(8)
Did you or someone else recently change the metadata in your Git account?Cavin
No, my account only I can use, other people can not use my account.Sapotaceous
Were those Git command above (beginning with git pull...) run before or after the error? If after, then the problem is likely that you changed your user credentials, and the repo host doesn't like it.Cavin
The Git command run before the error.Sapotaceous
Why did you change your information? This could cause problems with your Git history, making it difficult to track your previous work.Cavin
Sorry, I don't understand what do you mean?Sapotaceous
Git tracks user's commits via the info which you changed (I believe at least). When you change this, it is a bit like changing the credentials in your passport. Then no one can trace you anymore (think Jason Bourne).Cavin
Possible duplicate of Commiter email address does not match in IntelliJ even changing it to correct oneLissalissak
C
22

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
Cervantes answered 13/5, 2020 at 11:59 Comment(1)
Yes the first thing to do is check the author information in the commit you're trying to push, it's easy to overlook this!Panfish
S
9

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".

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 Committer permissions, so you'll get the very same error as mentioned in the question when trying to upload a new patch set.

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

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

git commit --amend --reset-author
Spratt answered 9/4, 2018 at 8:31 Comment(0)
V
3

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:

  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"

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.

Verdha answered 17/11, 2016 at 11:9 Comment(1)
The problem is the op probably does not have access to the aaa@aaa email address. Where did this come from and how to change it?Photoengraving
B
0

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

Here is the Fix, Just Execute :

git credential-manager clear <gerrit url>

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

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

Batfowl answered 29/12, 2017 at 13:46 Comment(0)
F
0

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

Fortney answered 16/7, 2018 at 3:53 Comment(0)
T
0

For me the issue was that I was using Cygwin and somehow wrong credentials got stored in .git-credential file inside Cygwin folder.

Location: cygwin/home/< username >/.git-credential

Corrected that and it worked fine afterwards.

Tommi answered 30/10, 2020 at 7:45 Comment(0)
M
0

If you are working on a shared windows account it is possible that git is trying to authenticate with a wrong credentials. In that case, open your local config:
$ git config --local --edit
And look at the section [remote "origin"] (or similar), check if you have added your user login to the url, it should looks something like that:
url = https://[email protected]/path/to/project
Additionally, you can check in Credential Manager on Windows what credentials you have saved on your account.

Manna answered 13/9, 2023 at 14:24 Comment(0)
R
0

As your commit will be with the old config creds run reset author, which will have the latest commit ready with commit id then push to your respective branches git commit --amend --reset-author

Rodd answered 24/4 at 18:50 Comment(0)
S
-1

another easy solution is open terminal

git config --global --edit

and update the email address to match with the Gerri account email address

Street answered 29/1, 2022 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.