Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: name and email address configuration

Tags:

git

Once in a while I get the message shown below from Git. My questions regarding this are:

  1. Why does this happen?
  2. How can I prevent this from happening again?
  3. How does this affect my commits or any other Git actions I may take?

I realize similar questions have been posted to Stack Overflow, but I don't believe they address this message in particular.


Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly:

git config --global user.name "Your Name" git config --global user.email [email protected] 

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author 
like image 473
Eric Brotto Avatar asked Jun 08 '12 10:06

Eric Brotto


People also ask

What is git config user name?

About Git usernamesYou can change the name that is associated with your Git commits using the git config command. The new name you set will be visible in any future commits you push to GitHub from the command line. If you'd like to keep your real name private, you can use any text as your Git username.

How can I see my git configuration details?

If you want to check your configuration settings, you can use the git config --list command to list all the settings Git can find at that point: $ git config --list user.name=John Doe [email protected] color.status=auto color.branch=auto color.interactive=auto color.diff=auto ...

What does git config --'global user email do?

You can use the git config command to change the email address you associate with your Git commits. The new email address you set will be visible in any future commits you push to GitHub.com from the command line.


1 Answers

Git simply detects you don't have the following section in your config files:

[user]     name = <your name>     email = <your mail> 
  • <project_path>/.git/config for the project specific config file.
  • ~/.gitconfig the global config file

When you do:

git config --global user.name "Your Name" git config --global user.email [email protected] 

Git writes that information into the configuration file (--global means in the global config file).

To have a the correct Author section in a commit like the following example commit:

commit 79eeaa9f22321580a0e5bee6e237331691cd3b68 Author: Sandro Munda <[email protected]> Date:   Thu Jun 8 10:40:05 2012 +0200      My first commit 

You need to reset the commit information with the command:

git commit --amend --reset-author

like image 129
Sandro Munda Avatar answered Oct 04 '22 17:10

Sandro Munda