How set git config username and email fields in global and local configuration files
Before you can issue a commit in Git, the user.name and user.email properties must be set. Without the git config username and email, the attempted commit will fail, and the following error message will returned:
fatal: unable to auto-detect email address
*** Please tell me who you are
Global git config
Fortunately, this fatal git error can be avoiding simply by issuing the following commands in the terminal to globally set git config username and email values:
git config --global user.email "[email protected]" git config --global user.name "cameronmcnz"
Just supply your own name and email address and Git commits will no longer be a problem. To verify that the changes have been saved successfully, you can show all git config settings by adding the –list switch to the base command.

Verify your git config email and username settings with the –list switch.
Git config email concerns
Privacy minded people aren’t wont to just hand over their email address every time an app or service asks for it. After all, nobody wants to be be spammed with unsolicited email. As such, some are leery about providing their email to Git config. They shouldn’t be.
The Git config email is not harvested for marketing purposes. It’s only use is to provide substance to the author metadata that is attached to every commit. Anyone looking through the Git log needs the ability to see who squashed a commit, performed a branch rebase, merged some code, added a Git tag or performed a commit. That’s all the git config user.name and user.email properties are used for. They don’t get used as part of a marketing campaign.
Furthermore, the git config email is not validated, so you can give it an address that is made up or malformed. The administrators on the DevOps team might not be impressed by such antics, but it will at least allow you to perform your commits without anxiety over privacy concerns.
Local git config email and usernames
Git allows you to set variables at the system, global, local and workingtree level. If you want to use a special name or email address for a specific Git repo, you can set the git config email and username fields at the local or worktree scope. Worktree overrides local, local overrides global and globel overrides system. This is the cascading nature of git config.
The command to set the local git config email and username is as follows:
git config --global user.email "[email protected]" git config --global user.name "cameronmcnz"
It can be annoying hitting the fatal: unable to auto-detect email address error message when you’re anxious to commit code to the local repository. But it’s a problem easily fixed. Just add your email and username to git config and the problem will go away for good.