28

Git push is getting rejected with the following error message:

expected committer email '' but found 'karan@xyz.com'

I have already tried:

  1. setting use properties in .gitconfig file.
  2. trying git push making different clones of same repository.
  3. setting up whole system all together after formatting it.

But none has worked. What else can I do to resolve it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Karan Singla
  • 373
  • 1
  • 4
  • 9

7 Answers7

71

This worked for me

git config --global user.name "Correct Name" 
git config --global user.email name@email.com 
git commit --amend --reset-author
Atul Soman
  • 4,612
  • 4
  • 30
  • 45
  • 4
    ``git commit --amend --reset-author`` worked for me, although my configured email was the correct one. So my commit history didn't change. – jmattheis Aug 10 '16 at 12:56
  • Great solution! I was stuck with how to amend the last commit for a long time. – bsky Mar 22 '17 at 16:34
18

This work for me:

git config --global user.name "Correct Name" 
git config --global user.email name@email.com 
git commit --amend --reset-author

It will show the screen where you can edit the commit message, after edit or keep it as it is, then press escape and then :wq and hit enter.

Then:

git push
Alexey Vazhnov
  • 1,291
  • 17
  • 20
Jaydeep Shil
  • 1,894
  • 22
  • 21
7

This doesn't seem like a git limitation, but should be some kind of pre-receive hook on the remote side (the Git repository hosting service/server to which you are pushing to)

That hook seems to parse the commits and check the committer email against a specific criteria which rejects karan@xyz.com.
You should check with the remote side administrator to see what is going on.


The OP Karan Singla confirms in the comments it was an issue at the server side:

Issue got resolved. Admin re-created my account and it is working fine now.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You mean to say that email address on Git repository hosting service/server is not set up properly. . So this error could be resolved from that side only? – Karan Singla Feb 10 '15 at 08:35
  • @KaranSingla it looks that way. Is it a privaye service (or gitHub or BitBucket) – VonC Feb 10 '15 at 08:42
  • it is a private service. What specifically should I be askingth the project host to correct so that I am able to push. – Karan Singla Feb 10 '15 at 08:46
  • @KaranSingla then I confirm: check with the admin of that private setting (for instance, if that service uses gitolite, there might be a VREF for checking the ID of committer, as I mention in http://stackoverflow.com/a/14605485/6309) – VonC Feb 10 '15 at 08:48
  • @KaranSingla more generally, ask the admin about the existence of any hook (like pre-receive or update) which might explain that behavior. – VonC Feb 10 '15 at 09:38
  • 1
    @VonC..thanks for the help. Issue got resolved. Admin re-created my account and it is working fine now. – Karan Singla Feb 10 '15 at 12:42
  • @KaranSingla do you know what in your previous account was incorrect? – VonC Feb 10 '15 at 12:43
  • @VonC...not really. . Admin person just recreated the account.I know it would have been great if I could share that information. – Karan Singla Feb 10 '15 at 12:47
  • @KaranSingla Ok. I have included your conclusion in the answer for more visibility. – VonC Feb 10 '15 at 12:49
4

Had a similar situation where a server side hook was involved, as @VonC mentioned, while trying to do the initial push to a empty Bitbucket Git repo (self-hosted in-house Bitbucket instance). The push contained commits from me and other earlier colleagues.

In my case it was the YACC (Yet Another Commit Checker) hook which complained about some e-mail addresses not known to the server. Those were used in commits during early project setup, by colleagues who meanwhile left the organization, and their accounts and e-mail adresses were meanwhile deleted. See also this Atlassian article.

But, instead of globally deactivating the hook (as suggested by the Atlassian article):

  • I have first explicitly activated the hook for my repo with empty settings: that overrides only for my repo the global hook settings with NOP ("no operation"),
  • then I made the initial push,
  • and then I disabled back the hook for my repo (global plugin remains active, but only with the server-wide hook settings!).
t0r0X
  • 4,212
  • 1
  • 38
  • 34
2
git config --list --show-origin

Allows you to see the file where the setting is coming from. In my case it was an unrelated git settings file somehow making it into my portable git install.screenshot of file list

Akin Okegbile
  • 1,108
  • 19
  • 36
0

I would suggest to open git terminal and set correct email. This worked for me when I encountered same issue.

git config --global user.email "your_correct_email@example.com"
David V
  • 2,134
  • 1
  • 16
  • 22
0

Try to set email like what you already set in your version control config(I used an email for creating ssh public key in bitbucket). After that I deleted and cloned again and used following commands and it worked.

git config --global user.email name@email.com 
git commit --amend --reset-author
Tohid Makari
  • 1,700
  • 3
  • 15
  • 29