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 install git -y
Once installed, you can verify by querying the path or use the git command.
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 –gloabl user.email “[email protected]”
The above commands should set the git global values. You can confirm using the command:
This command should show all the set values. If you have not done other configurations, this should only show the username and email.
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.
git config user.email “[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.