- [Cameron] Hey, Cameron McKenzie here.
I'm the editor-in-chief at the ServerSide.com
and I wanted to talk to you about the user.email property
that you got to configure in git
before you do your first commit.
Just wanted to make you feel good about user.email
and telling git what your email address is.
Don't worry.
This is not going to gonna go onto any mailing list
or anything like that.
This is just you
so that anybody that looks at the git log
is gonna see who did a particular commit
and when they realize just how smashing your code is
that they're gonna send you a nice little email
and tell you how great you are.
So, but it is required
and here I'll show you
how to set the user.email property in git config,
so that you can do all the commits that you like.
If you've just installed git,
before you can do any commits,
you got to tell git
what your username and your email address is.
Don't worry.
That information doesn't go anywhere
other than the git repository.
You're not gonna end up on a mailing list
or anything like that.
As you can see,
I just initialized a git repository here.
See that .git folder where all the configuration is.
And I can actually issue a lot of git commands.
I mean, there's git init right there,
I can do git status.
But if I want to actually create a file,
so, touch example.html.
And then add that to the index,
it's a step you have to do
before you do a commit.
You can see a lot of these git commands are working,
but if I now try and do a git commit
all of a sudden I get this error.
It says, "Hey.
We need your email address
and we need your username."
Now this is just used on git commits.
So that if somebody says,
"Hey, who wrote this great code?"
it'll say your name.
And if they say,
"Hey, I want to send somebody an award."
They know where to email you
to send that award.
So you know,
before you do this commit,
you need this field set.
And it's real easy to do.
You gonna just go git config--global.
I gonna tell it what to do,
as user.email.
And then git config.
And by the way, you can have a global.
You can also have a local
or system setting.
People usually do a global
because you do it once
and then that sets it up entirely for your account.
But let's do the user.name.
That's my Twitter handle
if anybody wants to follow me.
Also my GitHub and GitLab handle.
And now those things have been set.
You can always take a look at them.
git config--list will show you
all the different config settings that you have.
You see the email and the name.
They're separated like that
because I put them in different scopes.
Right, local and global.
You can even see where they're stored
if you're really interested.
But there you go.
That's how you set them up.
So you can see this one's in the git config setting,
that's global.
This one's in the local git repository,
that's local.
And now with that done,
you can go in
and you can commit to your heart's content,
git log--local.
You know, that's not a commit.
That looks like a commit.
And now we've got our commit.
And if I wanna do git reflog.
You can see,
yap, there's one commit.
If I wanna do git log,
you can see it's gonna give me a commit.
And here that information goes in.
There's the author name.
There's the email address.
That's what that information is used for.
So again don't worry.
You're not gonna get on the mailing list.
No one's gonna come knocking on your door.
That's just a way for people going through the git log
to be able to keep track of who made a particular commit
and maybe email them if there's questions about it.
And there you go.
Those are the ins and outs
of the git config user.email property.
If you enjoyed this tutorial,
why don't you head over to the ServerSide.com.
I'm the editor-in-chief over there.
We got lots of great tutorials
and get GitHub, GitLab DevOps tools
and anything that has to do
with enterprise software development
especially on the server-side.
If you want to follow my personal antics,
I'm @cameronmcnz on Twitter
and subscribe on YouTube.