Once in a while I get the message shown below from Git. My questions regarding this are:
- Why does this happen?
- How can I prevent this from happening again?
- 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 you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
Gitsimply detects you don’t have the following section in your config files:<project_path>/.git/configfor the project specific config file.~/.gitconfigthe global config fileWhen you do:
Git writes that information into the configuration file (
--globalmeans in the global config file).To have a the correct Author section in a commit like the following example commit:
You need to reset the commit information with the command:
git commit --amend --reset-author