When using Git, we may need to add different users to collaborate on development projects. This article will introduce how to add users in Git.
First of all, we need to know two basic information about users in Git: username and email. These two pieces of information are very important in Git. They will serve as the author information in the Git submission record, and are also important signs for Git to track and identify different users.
Next, we will introduce how to add global users and project local users in Git respectively.
1. Global user
The global user refers to the user information added in the global Git configuration file. This user will be used for the submission records of all warehouses by default. We can use the following command to add a global user:
$ git config --global user.name "Your Name" $ git config --global user.email "your_email@example.com"
where user.name
represents the user name and user.email
represents the email address. We just need to replace them with our own username and email.
If we want to view the information of the current global user, we can use the following command:
$ git config --global --list
This command will list all configuration information in the current global Git configuration file, including user name and email address .
2. Local user
Local user refers to the user information set for a specific Git warehouse. It will only take effect in that warehouse. We can use the following command to add a local user:
$ git config user.name "Your Name" $ git config user.email "your_email@example.com"
Similarly, user.name
and user.email
represent the user name and email respectively. We just need to replace them with our own information.
It should be noted that local user information will overwrite global user information. In other words, if we add local user information to a warehouse, the user information will be used first instead of the global user information.
If we want to view the current local user information, we can use the following command:
$ git config user.name $ git config user.email
This command will list the user name and email information set in the current warehouse.
Summary
This article introduces how to add users in Git. We understand the difference between global users and local users, and master the corresponding commands to add and view user information. I hope this article can help you add user information when using Git.
The above is the detailed content of How to add a user in git. For more information, please follow other related articles on the PHP Chinese website!