When using Git for version control, your username is an important part of your identity. It’s recorded in your commits and helps collaborators know who made what changes. Sometimes, you might need to check which username Git is currently configured to use on your machine.
This blog explains how to quickly check your Git username at both the global and local repository levels.
What Is the Git Username?
Git username is a configuration setting that identifies the author of commits. It is usually paired with your email address (user.email
). These details appear in commit logs and help keep track of contributors.
How to Check Git Username
Git stores configuration settings in three levels:
- System (applies to all users on the machine)
- Global (applies to your user account)
- Local (applies to the current repository)
Most users set their username globally, but it can also be overridden locally.
Step 1: Check Global Username
To see the username set for your entire system user (default for all repos), use:
git config --global user.name
If a username is configured, it will be displayed, for example:
Jane Developer
Step 2: Check Local Username
To check the username for the current Git repository only:
git config --local user.name
If nothing is returned, it means the local repo uses the global username.
Step 3: View All Git Configurations
To view all your Git settings, including username and email, run:
git config --list
Look for the line starting with user.name=
to find your configured username.
Why Check Your Git Username?
- Ensure commits are attributed to the correct person
- Troubleshoot commit identity issues
- Prepare your environment for new projects or collaborators
How to Update Your Git Username
If you need to change your username, run:
git config --global user.name "Your New Name"
Or for the current repository only:
git config --local user.name "Your New Name"
Summary
Command | Description |
---|---|
git config --global user.name | Check global username |
git config --local user.name | Check local repository username |
git config --list | List all Git configs including username |
Final Thoughts
Checking and managing your Git username is a quick but essential task for accurate commit tracking and collaboration. Keeping your Git identity correct helps maintain clean project history and proper credit.