How to Setting your user name and email in git.
You need to set who you are before creating any commit. That will allow commits to have the right author name and email associated to them.
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.
Tips: if you have different identities (one for open-source project, one at work, one for private repos, ...), and you don't want to forget to set the right one for each different repos you are working on:
Remove a global identity
git config --global --remove-section user.name
git config --global --remove-section user.email
Version ≥ 2.8
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
1. How to install git in your PC. Git Installation step by step easy explation.
2. How to create your first repository, then add and commit files in git step by step.
3. How to Clone a repository in git.
4. How to Share a code trough git.
5. How to Setting your user name and email in git.
6. How to Setting up the upstream remote in git.
0 Comments