0% found this document useful (0 votes)
76 views5 pages

1 - How To Configure Git Username and Email Address Global or Single Repository

This document discusses how to configure the Git username and email address globally and for a single repository. To configure globally, use the `git config --global` command followed by the `user.name` and `user.email` options. To configure for a single repository, run the same commands without the `--global` flag from within the repository directory. The configuration values are stored in the `.gitconfig` file globally and `.git/config` file locally per repository.

Uploaded by

Kashif Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views5 pages

1 - How To Configure Git Username and Email Address Global or Single Repository

This document discusses how to configure the Git username and email address globally and for a single repository. To configure globally, use the `git config --global` command followed by the `user.name` and `user.email` options. To configure for a single repository, run the same commands without the `--global` flag from within the repository directory. The configuration values are stored in the `.gitconfig` file globally and `.git/config` file locally per repository.

Uploaded by

Kashif Kamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

https://linuxhint.

com/configure-git-username-email-address/

https://linuxize.com/post/how-to-configure-git-username-and-email/

How to Setup Global Configuration of Git on CentOS 8


To change the username and email address of Git globally, the commit messages will have the
correct information about the user in every project. We can configure both username and email
address using the git config command with the --global flag as shown in the commands given
below:

Setting your Git username for every repository on your computer

$ git config --global user.name "user_name"


$ git config --global user.email "[email protected]"

Confirm that you have set the Git username correctly:


$ git config --global user.name
> Mona Lisa

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:

$ git config --list

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:

$ sudo nano ~/.gitconfig


After changing it as per your desire, save the file and exit using the keyboard shortcut keys CTRL
+ S and CTRL + X.

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

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.

How to Configure Git in a single Repository


If you want to use a different username or email address for a specific repository, run the git
config command without the --global option from within the repository directory.

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:

$ git config user.name "user_name"


$ git config user.email "[email protected]"

Confirm that you have set the Git username correctly:


$ git config user.name
> Mona Lisa

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:

Verify that the changes were made correctly:

$ git config --list


The above command will show the information straight out.
This information will definitely store in the ‘.git/config’ configuration file (under the root directory
of the repository.), and you can edit that information using the command provided below:

$ sudo nano ~/.gitconfig

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.

You might also like