The fastest way to see your Git username
Open your terminal and run git config user.name. That command returns the name Git has stored for you on your machine. If nothing appears, Git does not have a username set yet — you will need to add one before you can commit changes.
The username Git shows is the one that will appear on every commit you make from that computer. It is not your GitHub account name or any online identifier — it is a local setting stored on your machine. When you push commits to a repository hosting service like GitHub or GitLab, the name you set here is what shows up in the commit history.
Key Takeaways
- Run git config user.name in your terminal to see the username Git has stored on your current machine.
- If the command returns nothing, you have not set a Git username yet and need to configure one before making commits.
- The username Git shows is a local setting on your machine, separate from your GitHub or GitLab account name.
- Use git config --global user.name "Your Name" to set a username that applies to all repositories on your machine.
- Use git config user.name "Your Name" without the --global flag to set a username for only the current repository.
Check your email address at the same time
While you are checking your username, you can also see the email Git has stored. Run git config user.email to display it. Both the username and email appear together on every commit you make, so it is useful to verify both are correct before you start working.
If either one is wrong or missing, you can update them with git config user.email "your.email@example.com" for email or git config user.name "Your Name" for username. These commands change the setting for the current repository only. To change them globally across all your repositories, add the --global flag to either command.
The difference between global and local settings
Git stores username settings in two places: globally (for all repositories on your machine) and locally (for one repository only). When you run git config user.name without any flags, Git shows the local setting if one exists. If no local setting exists, it shows the global one instead.
To see your global username specifically, run git config --global user.name. To see the local setting for just the current repository, run git config user.name from inside that repository folder. If you want to see all your Git settings at once, run git config --list — this shows both global and local settings, with local ones appearing twice if they override the global version. This is helpful when you have set different usernames for different projects.
Setting a username if you do not have one
If git config user.name returns nothing, you need to set a username before you can commit. Navigate to the repository folder in your terminal and run git config user.name "Your Name", replacing "Your Name" with whatever name you want to appear on your commits. This sets the username for that repository only.
If you want the same username to explore to all repositories on your machine, add the --global flag: git config --global user.name "Your Name". Most people set a global username once and then do not change it. After you run either command, verify it worked by running git config user.name again — it should now display the name you just entered. You should also set your email address at the same time using git config user.email or git config --global user.email.
Where Git stores these settings
Global settings live in a hidden file in your home directory called .gitconfig. You can view it by running cat ~/.gitconfig in your terminal. Local settings for a specific repository are stored in a hidden folder called .git inside that repository, in a file called config. You can view the local config by running cat .git/config from inside the repository folder.
You do not need to edit these files directly — using the git config command is the standard way to change settings. But knowing where they live helps if you ever need to troubleshoot or move settings between machines. If you want to copy your Git configuration to a different computer, you can copy the .gitconfig file from your home directory to the new machine, and all your global settings will transfer with it.
Frequently Asked Questions
What if git config user.name shows a name I did not set?
Git may have picked up a default username from your system or from a previous installation. You can change it by running git config user.name "Your Name" to update just the current repository, or git config --global user.name "Your Name" to change it everywhere on your machine.
Can I have different usernames for different repositories?
Yes. Set a global username with git config --global user.name "Your Name", then navigate to a specific repository and run git config user.name "Different Name" without the --global flag. That repository will use the local name, while all others use the global one.
Does my Git username have to match my GitHub username?
No. Your Git username is a local setting on your machine and can be anything. Your GitHub username is separate. However, many people use the same name for both to avoid confusion. The name you set in Git appears on commits; GitHub matches commits to your account based on the email address, not the name.
What happens if I commit without setting a username?
Git will not let you commit. You will see an error message asking you to set user.name and user.email. The error message includes the exact commands to run. Once you set both, you can commit normally.
How do I change my username for commits I have already made?
Changing your Git username only affects new commits going forward. Old commits keep the name that was set when you made them. If you need to change the author name on existing commits, you would need to rewrite the repository history, which is complex and should only be done if you are working alone on a repository.