git config command
After installing the Git, we need to configure some basic information in the git. We do not need to register for an account or anything, but we will need to provide:
• Your name
• Your email
If we are using a GUI, it should prompt us for our name and email the first time we open the app.
To configure Git, we must define some global variables: user.name and user.email. Both are required for us to make commits.
To set our name in the bash use the following command.
Bash
Replace <USER_NAME> with the username we want to use.
Note: Use double quotes when there is a space in name otherwise it is not required to use double quotes.
Example:
Bash
To validate that it is set or not, we can use the following command, it will return the name.
Bash
Now, use the following command to create a user.email configuration variable, replacing <USER_EMAIL> with our e-mail address:
Bash
Example:
Bash
To validate that it is set or not, we can use the following command, it will return the email.
Bash
Note: 1. To integrate with github, git email address match with the github account Email.
2. If we want to override user with a different name or email address for specific projects, we can run the command without the --global option when we are in that project.
If we want to see all the configuration details, we can use the following command in git:
Bash
Confirm that the output includes two lines that are similar to the following example. Our name and e-mail address will be different from what's shown in the example.
Output
user.name=Ashish
user.email=example@gmail.com