How to Set Up Git Username and Email on Ubuntu
You set up your Git username and email on Ubuntu using simple terminal commands.
Git is a distributed version control system that tracks changes to your files. Every time you make a commit, Git attaches your configured username and email to that record, ensuring your contributions are properly attributed.
This is crucial for project history and collaboration, especially on platforms like GitHub or GitLab, where your name will appear next to every change you push.
Configuring your Git identity on Ubuntu is straightforward and ensures your work is always recognized accurately, even when collaborating with multiple developers on a project.
Configure your Git username and email on Ubuntu using the terminal. Run `git config –global user.name “Your Name”` and `git config –global user.email “your_email@example.com”` to set your global credentials.
Installing Git
Before we dive into setting your username and email, make sure Git is installed on your machine. If it’s not, open your terminal and run this command:
sudo apt update sudo apt install git
Configure Git Username and Email
Once Git is ready, you can configure your username and email. This is done using the git config command.
You can set this globally or for a specific repository. To set your global commit name and email address, run the git config command with the --global option.
Setting your Global Username
Open your terminal.
Type the following command to set your global Git username:
git config --global user.name "User_name" Replace "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 "your_email@example.com" Replace "your_email@example.com" with your actual email address. This should be the email address linked to your Git or GitHub account.
Setting Username and Email for a Single Repository
If you need a different username or email for a specific project, you can set that within the project’s directory.
Navigate to the project directory:
cd path/to/your/project 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 "project_specific_email@example.com" Verifying your Configuration
After configuring your username and email, you can check your settings with the git config --list command.
git config --list
This will show all your Git configuration settings. Look for user.name and user.email 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
Repository-specific settings are stored in the .git/config file, found in the root directory of your project.
If the information is correct, your Git setup is finished! Any commits you make from now on will use your configured username and email address.
If you ever need to change these settings, run the git config command again with your new values.
That’s it!
Conclusion:
- Configuring your Git username and email is crucial for ensuring proper attribution of your commits
- The proper contact information associated with your commits can facilitate communication with other developers
- Installing Git and configuring your username and email are essential steps for a smooth Git setup on Ubuntu Linux
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!