Git Author != Committer
It may be quite confusing, but in git ‘commit author’ and ‘committer’ are separate beasts.
Let’s imagine you have a remote Gerrit repo and you noticed your last commit has author’s email configured as [email protected]:
commit af434be3126cfbcaf450b04137d4d09cd87f8a47
Author: Name Surname <[email protected]>
Date: Sat Dec 10 20:34:30 2016 -0800
Add more bewbs
Change-Id: Idca25cc30ac8ee311ac93a962e1c2f3d3e9a3416
Gerrit expects it to be [email protected]. So an attempt to push change request to the community repo results in error
remote: ERROR: In commit af434be3126cfbcaf450b04137d4d09cd87f8a47
remote: ERROR: committer email address [email protected]
remote: ERROR: does not match your user account.
remote: ERROR:
remote: ERROR: The following addresses are currently registered:
remote: ERROR: [email protected]
Ok, we can amend the commit and reset the author
git commit --amend --no-edit --author 'Name Surname <[email protected]>'
git log
shows author’s email is correct now:
commit c82db34717123c9e3c31c3a330dd81059880afac
Author: Name Surname <[email protected]>
Date: Sat Dec 10 20:34:30 2016 -0800
Add more bewbs
Change-Id: Idca25cc30ac8ee311ac93a962e1c2f3d3e9a3416
but does push works now? Nope!
remote: ERROR: In commit c82db34717123c9e3c31c3a330dd81059880afac
remote: ERROR: committer email address [email protected]
remote: ERROR: does not match your user account.
remote: ERROR:
remote: ERROR: The following addresses are currently registered:
remote: ERROR: [email protected]
what the heck? The answer is quite simple - we didn’t reset committer’s email along with author’s one. Let’s check git log with ‘fuller’ option supplied.
git log --format=fuller
commit c82db34717123c9e3c31c3a330dd81059880afac
Author: Name Surname <[email protected]>
AuthorDate: Sat Dec 10 20:34:30 2016 -0800
Commit: Name Surname <[email protected]>
CommitDate: Sat Dec 10 20:35:24 2016 -0800
Add more bewbs
Change-Id: Idca25cc30ac8ee311ac93a962e1c2f3d3e9a3416
this is the reason. You want to export GIT_COMMITTER_EMAIL variable
export [email protected]
and, potentially, GIT_COMMITTER_NAME prior to the rebase so committer information is being set correctly.