60

I am doing a git commit --amend and I get this error:

fatal: empty ident name (for <>) not allowed

I've found a bunch of stuff saying I need to set my user.email and user.name, but I have. This is the the result when I do a git config --global --list:

core.exludesfile=/home/dzou/.gitignore
core.editor=vim
user.email=dzou@company.com
user.name=dzou

What is going on here?

dippas
  • 58,591
  • 15
  • 114
  • 126
Di Zou
  • 4,469
  • 13
  • 59
  • 88

12 Answers12

65

Set global user.name and user.email first by order like below.

$ git config --global user.name "dzou"
$ git config --global user.email "dzou@company.com"

NB: careful, use double quote instead of single quotes

dippas
  • 58,591
  • 15
  • 114
  • 126
  • 3
    I had already done that before, but it didn't work. I just did it again, and it now works. What happened? Thanks! – Di Zou Apr 27 '17 at 15:46
  • 5
    So I looked in my history and the previous commands I ran didn't have quotes around my name/email or they had single quotes around my name/email. That's probably why it wasn't working. – Di Zou Apr 27 '17 at 15:48
  • 1
    the above answer did the trick for me. Didn't know that I need to set username first before setting user email. Ty! – claudios Jun 19 '18 at 02:33
  • 1
    @claudios FWIW my Git client recommends running `git config --global user.email "you@example.com"` and then `git config --global user.name "Your Name"` and yours probably does too. – Jason Young Mar 19 '19 at 17:54
  • 4
    @dippas, I did this and still get the error described in the question. Any ideas? – ChaseHardin Aug 01 '19 at 15:23
  • @ChaseHardin have you read the above comments carefully? they might help you as well or the below answers – dippas Aug 01 '19 at 15:25
  • @dippas yes I've read and tried the other comments. I figured running `git config --global user.name "FIRST_NAME LAST_NAME"` and `git config --global user.email "MY_NAME@example.com"` would've resolved it. When running `git config --local -e` I see my username/email – ChaseHardin Aug 01 '19 at 15:29
15

I had a similar problem because when I committed, the user.email was set correctly but user.name was empty. So even if I set the user name in the config, still I've got the same "empty ident" error.

I fixed it adding --reset-author to the amend command (after setting the correct user.name)

$ git commit --amend --reset-author
dippas
  • 58,591
  • 15
  • 114
  • 126
G. Verni
  • 667
  • 5
  • 8
  • This seems like the best answer considering the "symptoms" of the question. I had the same issue with the `fatal: empty ident name (for .localdomain>) not allowed` message, also after setting the username and email address. So one part of the issue lied there (that's the obvious part), but this part with the `--reset-author` was what I was missing. – Olov Dec 26 '20 at 12:07
  • What I find weird though, is that I was able to do a simple `commit` without setting any username or email, and that's when the commit ident name became `.localdomain>`. But when doing a `commit --amend`, the error message appeared. – Olov Dec 26 '20 at 12:14
  • Well well. What do you know... this seemed to be the least promising of all the answers, but, after all, it did the job! Thanks guys :) – Gwyneth Llewelyn Dec 22 '22 at 20:21
9

Fixed it by deleting local config and using the global configuration

$ git config --local -e

now delete all local lines and save the empty file

dippas
  • 58,591
  • 15
  • 114
  • 126
scilicet64
  • 99
  • 1
  • 1
  • exactly that was my issue. Although the global configuration was set, the local one had an empty name and email. – olio Apr 02 '23 at 20:23
7

A local setting can easily override the global settings! Just had this happen to me - while I did a really dirty fix using someone elses repo.

$ git config --local -e

let's you remove or change the local values that disturb your commit!

Rautermann
  • 334
  • 3
  • 10
  • 1
    I ended up using this approach after the others failed. In my case, my user.name was defined correctly globally but in my local config I had an extra user.name entry which was empty at the bottom of the file that was causing the error. – Terry Ray Jul 01 '21 at 18:35
7

For anyone that comes later, I had a similar problem but even after setting local and global config I was getting the same error.

My problem was that I had this in ~/.bashrc

export GIT_AUTHOR_NAME=""
export GIT_AUTHOR_EMAIL=""

These variables override the other settings. I forgot that I had done it precisely to stop people from trying to commit from the production server :)

The tricky bit is that I have git 1.7.1 on that server and env variables don't show up with

git config --list

The fix was to set values for those variables which is valid only for a session (and exactly what I needed).

export GIT_AUTHOR_NAME="RaiderOfTheLostBBS"
export GIT_AUTHOR_EMAIL="email@example.com"
3

I got the same problem after doing some filter-branch without using quotes too. That created a new user without any information hence the error, so the suggestion of configuring your own user name and email won't help.

I manged to fix it by editing the config file and removing the empty user. You can run

$ git config --global -e  

and deleting the [user] line that doesn't have any member field. I had to do a reboot too but it works after that. Hope that helps!

dippas
  • 58,591
  • 15
  • 114
  • 126
emilyfy
  • 183
  • 1
  • 8
3

In case someone still needs help with this. What I did was, I entered my name as the user.name instead of the email and it worked.

git config --global user.name Kunle
Ruli
  • 2,592
  • 12
  • 30
  • 40
Ozone183
  • 31
  • 2
1

vi .git/config

Edit the missing user name or email values in the file and save it.

Wings2fly
  • 887
  • 1
  • 11
  • 31
1

Similar to the response by "Raider of the lost BBS" (which I can't reply to, due to insufficient reputation points), but I was on a shared system, which did not have user.email or user.name set. I tried: export GIT_AUTHOR_NAME="Firstname Lastname" and export GIT_AUTHOR_EMAIL="first.last@org.org" and then git commit --author="Firstname Lastname <first.last@org.org>". This still produced an error that included Committer identity unknown and fatal: empty ident name (for <otheruser@machine.edu>) not allowed (details obfuscated, of course). This was confusing, since I thought I was providing my identity twice, through the environment variables and the author flag.

Since editing either ~/.gitconfig or <repo>/.git/config were not viable options, I kept at it and finally got it to work by setting: export GIT_COMMITTER_NAME="Firstname Lastname" and export GIT_COMMITTER_EMAIL="first.last@org.org" (with GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL still set), then running the same commit command. That worked for me.

user858789
  • 23
  • 4
0
  1. let me know, if you are using git on Windows Operating System. Windows needs .Net Framework 4.8 to run git. so first install it first

  2. clone your git repository: git clone https://github.com/userName/yourRepo.git

  3. Open your repository folder

  4. now run git-bash

  5. type following commands git config --global user.name "Your User name On Github"

    git config --global user.email "Your Registered Email on github"

    git config --global user.password "Your Github password"

Adal Khan
  • 19
  • 2
0

I had same problem and I solved by removing [user] stage in config file in .git folder in the repository

nano .git/config
morteza khadem
  • 346
  • 3
  • 8
0

Create .gitconfig file in your $HOME path:

$ cat $HOME/.gitconfig
[user]
        name = daniel
        email = daniel@andrzejewski.it
[push]
        default = matching
        default = matching

With this file in place I stopped getting the error "fatal: empty ident name (for ...) not allowed"