Git configuration user.name doesn't work

47,085

Solution 1

You're not using the correct syntax: there shouldn't be any equal sign between user.name and "My name", or between user.email and "[email protected]". For instance, when you run

git config --global user.name = "My Name"

the command interprets the = character as the string value passed to the user.name key, and the rest of the line ("My Name") is silently ignored. That's why your .gitconfig file ends up containing

[user]
    name = =
    email = =

Everything should work if you use the correct syntax:

enter image description here

See also VonC's answer about relevant changes in Git 2.13.

Solution 2

There is no "=" for the parameters user.name and user.email, just use spaces. From the same page -

The first thing you should do when you install Git is to set your user name and e-mail address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you pass around:

  • $ git config --global user.name "John Doe"
  • $ git config --global user.email [email protected]

Solution 3

Note: that kind of syntax error (git config --global user.email = "[email protected]") will be better reported by Git 2.13+ (Q2 2017)

See commit 9442555, commit 13b9a24, commit 862e80a, commit afb6c30 (23 Feb 2017) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 066c38c, 10 Mar 2017)

user.email that consists of only cruft chars should consistently error out, but didn't.

That means this will now fail:

GIT_AUTHOR_NAME=" .;<>" git commit --allow-empty -m foo
fatal: name consists only of disallowed characters: .;<>

GIT_AUTHOR_EMAIL="" GIT_AUTHOR_NAME="" git commit --allow-empty -m foo 
fatal: no email was given and auto-detection is disabled
Share:
47,085
Jimsea
Author by

Jimsea

Updated on July 11, 2022

Comments

  • Jimsea
    Jimsea almost 2 years

    I installed Git for Windows 7 today. I don't know much about Git yet and I'm following http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup and videos from YouTube on that subject. On the videos people install Git and go to the command line and use

    git config --global user.name = "My Name"
    

    and

    git config --global user.email = "[email protected]"
    

    and it creates .gitconfig file in C:/Users/admin/.gitconfig with correct values for them.

    After running the above lines of code three times this is what I got in that file:

    [user]
        name = =
        email = =
        name = =
    

    Why isn't it working? I followed the official tutorial and I see that it works for other people on YouTube but not for me.