How to Set Git Username and Email Address

Git is a distributed version control system that has become one of the most popular and must-have technologies for any geek. Git provides many features, including distributed development that allows multiple developers to work on a single project concurrently.

The very first thing you need to do after installing git is to configure your repository settings. Doing this allows you to perform operations on local and remote repositories, including commits and pull requests.

This tutorial will examine how to configure your git username and password for global usage, allowing you to use the email address and username on all your repositories or config for a specific repository.

How to Install Git On Your System

Before we get to the configuration, we need to ensure you have git installed and working on your system. In this guide, I will be using an Ubuntu system. However, git is relatively easy to install on your system, including Windows and Mac.

To install git on Debian/Ubuntu, use the command:

sudo apt-get update
sudo apt-get install git -y

Once installed, you can verify by querying the path or use the git command.

which git

Configuring git

Now that we have git installed and working on our system, we can perform basic configuration settings.

How to set Global Username and Email

A global username and email come in handy in the place where we have no specific credentials set. To configure the global values, use the command:

git config --global “Username”
git config –gloabl “[email protected]

The above commands should set the git global values. You can confirm using the command:

git config --list

This command should show all the set values. If you have not done other configurations, this should only show the username and email.
[email protected]

Set username and email for a repo

Suppose you want to use a different username and email for a specific repo. In that case, you can use the git config without the –global option.

That creates a local .git/config file in that specific repository and adds the specified username and passwords for that repository.

For example:

git config “Local username”
git config “[email protected]

NOTE: Ensure you are in the repository’s root directory to specify a local username and email address.


That’s it for this guide.

In this one, we talked about setting your git environment values using the git config command. If you are new to version and git in general, consider our other tutorials on how to perform various actions in git.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list