32

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@example.com"

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.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Jimsea
  • 585
  • 1
  • 6
  • 11

6 Answers6

58

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@example.com". 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.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
  • 2
    You're right, that's my mistake. After seeing another answer I noticed that I had redundant `=` there. – Jimsea Aug 31 '14 at 14:49
10

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 johndoe@example.com
factotum
  • 900
  • 10
  • 13
3

Note: that kind of syntax error (git config --global user.email = "email@example.com") 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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

For those coming to this much later, and want to simply have their credentials stored because SSH isn't available, use the following:

git config --global credential.helper store
eugene
  • 956
  • 1
  • 11
  • 13
0

There was no space in my command:

git config --global user.name="parsecer"

should be

git config --global user.name = "parsecer"
parsecer
  • 4,758
  • 13
  • 71
  • 140
-3

use

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

Abhishek kumar
  • 245
  • 2
  • 3