In this post, I will help you set up an identity for your git repository on your local environment. We can config git username and email address for your repository or globally for your users. The global configuration is applied to all repositories to that user. The Git local repository configuration overrides the global configuration.
What command to config git username and email ?
Firstly, Search and show information GIT Username and Email
1. Use git config command
git config <option>
– List all git configs
git config --list
– Show Git User
git config user.name
– Show Git Email
git config user.email
2. Search in git’s ~/.gitconfig file
For example, The content in the file ~/.gitconfig will look like below:
[user] name = Admin email = admin@sitesharing.net
Change Global Git Config
However, If you have multiple repository on your computer. And you don’t want to configure username and email address for each repository individually.
Therefore, You can use –global option with that commands to configure it globally. And it will be available for all repositories of that system user.
And run below command to config
git config --global user.name "Admin"
git config --global user.email "admin@sitesharing.com"
Or edit ~/.gitconfig file before commit
Change Local GIT Config for each project
In addition, In case you want to set the user for each project, edit the .git/config file in each project. It will override the user and email upon commit.
For instance, the command to set the local git config is as follows:
git config user.name "Admin" git config user.email "admin@sitesharing.com"
However, If you have any questions or comments, feel free to contact me here or comment below the post