Setting your user name and email
suggest changeSet who you are before you create a commit. That stores the author name and email on the commit.
It has nothing to do with authentication when pushing to a remote repository (e.g. when pushing to a remote repository using your GitHub, BitBucket, or GitLab account)
To declare that identity for all repositories, use git config --global
This will store the setting in your user’s .gitconfig file: e.g. $HOME/.gitconfig or for Windows, %USERPROFILE%\.gitconfig.
git config --global user.name "Your Name"
git config --global user.email mail@example.com
To declare an identity for a single repository, use git config inside a repo.
This will store the setting inside the individual repository, in the file $GIT_DIR/config. e.g. /path/to/your/repo/.git/config.
cd /path/to/my/repo
git config user.name "Your Login At Work"
git config user.email mail_at_work@example.com
Settings stored in a repository’s config file will take precedence over the global config when you use that repository.
If you use different identities (open source, work, private repositories) and you do not want to forget which one belongs on each repository:
- Remove a global identity
git config --global --unset user.name
git config --global --unset user.email
- To force git to look for your identity only within a repository’s settings, not in the global config:
git config --global user.useConfigOnly true
That way, if you forget to set your user.name and user.email for a given repository and try to make a commit, you will see:
no name was given and auto-detection is disabled
no email was given and auto-detection is disabled