Professional Documents
Culture Documents
1 - How To Configure Git Username and Email Address Global or Single Repository
1 - How To Configure Git Username and Email Address Global or Single Repository
com/configure-git-username-email-address/
https://linuxize.com/post/how-to-configure-git-username-and-email/
After successfully configuring the username and email address globally, you can view the
information about the Git user using the command:
Once done, you can confirm that the information is set by running:
The above command will show the information of the Git user.
This information is stored in the ‘.gitconfig’ configuration file of the Git, and if you want to edit
that information, you can use the command provided below and change it to your desire:
The command saves the values in the global configuration file, ~/.gitconfig:
You can also edit the file with your text editor, but it is recommended to use the git config
command.
What if you do not want to change it globally but only in the project’s directory. Let’s see how we
can change Git Username and email address in a single repository.
To change the username and email address of Git in a single repository only so that the commit
messages inside that repository will have different information about the user.
First, you have to navigate to the directory in which the project is set up or if there is no project
directory, create a directory using the ‘mkdir’ command:
$ mkdir projectDirectory
Then, navigate to the newly created project directory.
$ cd projectDirectory
Once you are in the project’s directory, initialize the git repository using the command:
$ git init
the method for configuring both username and email address will be the same using the git
config command but without the --global flag as shown in the commands given below:
This way, you can successfully configure the username and email address of the user inside a
single repository; you can view the information about the Git user using the command:
After changing it as per your desire, save the file and exit using the keyboard shortcut keys CTRL
+ S and CTRL + X.
The repository-specific setting are kept in the .git/config file under the root directory of the
repository.
Conclusion
This is all about how you can configure and change the username and Email address of the Git
user globally and inside a single repository. After reading this post, you can have a different
username and email address in every different project.