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.

LayaCCC
  • 415
  • 1
  • 5
  • 12
  • Did you or someone else recently change the metadata in your Git account? – Tim Biegeleisen Nov 17 '16 at 09:22
  • No, my account only I can use, other people can not use my account. – LayaCCC Nov 17 '16 at 09:35
  • 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. – Tim Biegeleisen Nov 17 '16 at 09:36
  • The Git command run before the error. – LayaCCC Nov 17 '16 at 09:51
  • Why did you change your information? This could cause problems with your Git history, making it difficult to track your previous work. – Tim Biegeleisen Nov 17 '16 at 09:51
  • Sorry, I don't understand what do you mean? – LayaCCC Nov 17 '16 at 15:30
  • 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). – Tim Biegeleisen Nov 17 '16 at 15:36
  • Possible duplicate of [Commiter email address does not match in IntelliJ even changing it to correct one](https://stackoverflow.com/questions/31652094/commiter-email-address-does-not-match-in-intellij-even-changing-it-to-correct-on) – Saint May 17 '18 at 02:16

7 Answers7

20

You can run these commands:

git config --global user.name "Your Name"
git config --global user.email you@example.com

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

git commit --amend --reset-author
BSMP
  • 4,596
  • 8
  • 33
  • 44
Bhargava GM
  • 201
  • 2
  • 2
  • 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! – chrisinmtown Jul 23 '20 at 10:37
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
The Godfather
  • 4,235
  • 4
  • 39
  • 61
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.

  • 3
    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? – user2441441 Apr 04 '17 at 20:37
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

Lokkesh
  • 550
  • 3
  • 11
0

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

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.

-1

another easy solution is open terminal

git config --global --edit

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

glennsl
  • 28,186
  • 12
  • 57
  • 75
Rehan
  • 1