Blog

18
November 2013

Gavin Pickin

Git for Dummies - How to set your Name and Email Address in Git

Source Control

We have walked through a lot of different tasks in this Git for Dummies series so far, but there is something I forgot to mention when I wrote the first few. I will go back and update Installing Git on WindowsInstalling Git on Mac OSXInstalling Git on Linux,  and Your First Repo, but I wanted to add a separate entry, for those who have already read those, and might not go back and see the update.

Depending on how your machine is setup, Git can sometimes guess what your Name, and Email Address are, and will use those when storing your commit, so you have more meaningful tracking information. My machines are either setup for auto-detection, or I had set that global setting in git, so I completely missed that step in the walk throughs, until someone reminded me, so here I am, coming back to fill in the gap.

If you try and make a commit... and git cannot auto-detect that information, you will see something like this.

Git is nice enough to give you the issue, and the resolution, so you probably do not need this walkthrough, but still, this series is for Dummies, and sometimes its better to have a walkthrough to follow, than some seemingly good on screen advice... but in this case... its good advice.

So we'll run the commands below

$ git config --global user.email "gpickin@skiion.com"
$ git config --global user.name "Gavin Pickin"

You can see there is no output, therefore you assume it worked.

Note, as stated in the helpful output git gives you when it cannot determine your identity... you can globally set your Name and Email address, as I am showing you, or you can use the following commands to just set the Name and Email address for that given repo.

$ git config user.email "gpickin@skiion.com"
$ git config user.name "Gavin Pickin"

So, now we can try the commit again, and see if it works.

$ git commit -m "Initial Commit from Production"

And you see the commit does it's thing, creating mode this and that... no problem.

Sorry for missing this simple step, I'll add it to the old walkthroughs just in case.
Hope it helps on your Git Journey.

Check back soon for the next entry in our Git for Dummies Series.

Blog Search