This article explains configuring Git username and email address on Ubuntu Linux.
Git is a distributed version control system widely used for software development and other version control tasks. When you make commits in Git, it records your username and email address in those commits.
Learning how to configure your Git username and email address is important because it helps to ensure that your commits are correctly attributed to you. This is especially useful when working on projects with other developers or contributing to open-source projects.
By setting up your Git username and email correctly, you can ensure that your contributions are properly recognized and that you receive credit for your work.
Additionally, having the correct contact information associated with your commits can be helpful in case other developers need to contact you about your contributions.
Before we begin, you need to have Git installed on your machine. If it’s not installed, open a terminal and run the following command:
sudo apt update sudo apt install git
Configure Git Username and Email
Once Git is installed, you can configure your username and email using the
git config command.
This can be set on a global or a local repository level. To set your global commit name and email address, run the
git config command with the
Setting your Global Username
Open your terminal.
Type the following command to set your global Git username:
git config --global user.name "User_name"
"Your Name" with your name or the username you want to use for your Git commits.
Setting your Global Email Address
In the terminal, enter the following command to set your global email address:
git config --global user.email "email@example.com"
"firstname.lastname@example.org" with your actual email address. This should be the email address associated with your Git or GitHub account.
Setting Username and Email for a Single Repository
If you want to use a different username or email for a specific project, you can set that within the project’s directory.
Navigate to the project directory:
Set the local username for this repository:
git config user.name "Project Specific Name"
Set the local email address for this repository:
git config user.email "email@example.com"
Verifying your Configuration
After configuring your username and email, you can check your configuration by using the
git config --list command.
git config --list
This will list all the Git configuration settings. You can specifically check for
user.email settings to verify your configurations.
Checking Global Configuration
git config --global user.name git config --global user.email
Checking Local Configuration
git config user.name git config user.email
The repository-specific settings are stored in the
.git/config, located in the root directory of the repository.
If the information is correct, your Git setup is complete, and any subsequent commits will be made using your configured username and email address.
If you need to change these settings at any point, simply run the
git config command again with the new values.
This post showed you how to set up your username and email address in Git on Ubuntu Linux. Please use the comments form below if you find errors or have something to add.