Back to blog
Apr 29, 2024
2 min read

Configure user.name and user.email for Git

Set Git user.name and user.email using git config --global for global settings or git config for local.

Terminal on Ubuntu Linux

Photo by Yancy Min on Unsplash

Git is a distributed version control system used for tracking changes in source code. Configuring user.name and `user.email is essential because it identifies the author of each commit. Here’s a simple guide to set them up:

Setting Global Configuration

To set your name and email globally, meaning it will apply to all repositories on your machine, use the following commands:

# Set the global user name
git config --global user.name "Your Name"

# Set the global user email
git config --global user.email "your.email@example.com"

Setting Local Configuration

To set the configuration for a specific repository, navigate to the repository’s directory and use the following commands:

# Set the local user name
git config user.name "Your Local Name"

# Set the local user email
git config user.email "your.local.email@example.com"

Checking the Configuration

To check the current global and local configurations, use these commands:

# Check global configurations
git config --global --list

# Check local configurations
git config --list

Conclusion

By following these steps, you can set up and confirm your Git configurations for user.name and user.email. This will ensure that your commits are properly attributed to you.