Check your username with a single command
Open your terminal or command prompt and run git config user.name. Git will print the name you set up when you first configured it on that computer. If nothing appears, you haven't set a username yet on this machine — even if you have one on GitHub or another service.
The username Git shows you is what appears in your commit history. It's not necessarily the same as your GitHub login, your email address, or your account name anywhere else. Git stores this locally on your computer, separate from any online account.
Key Takeaways
- Run git config user.name in your terminal to see the username Git is currently using on your computer.
- This username is stored locally and may differ from your GitHub username, email, or other online accounts.
- If nothing prints, you need to set a username before making commits.
- Use git config --global user.name "Your Name" to set a username that applies to all repositories on your computer.
- Use git config user.name "Your Name" (without --global) to set a username for only the current repository.
The difference between global and local usernames
Git lets you set a username in two ways: globally (for every repository on your computer) or locally (for just one repository). When you run git config user.name without any flags, Git checks the local setting first. If no local setting exists, it uses the global one.
Most people set a global username once and never change it. But if you work on projects where you need a different name — perhaps a work project under your full legal name and a personal project under a nickname — you can override the global setting by running git config user.name "Different Name" inside that specific repository folder.
How to see all your Git settings at once
Run git config --list to see every setting Git knows about on your computer. This includes user.name, user.email, and dozens of other options. The output can be long, so you can pipe it through grep to find just what you need: git config --list | grep user (on Mac or Linux) or git config --list | findstr user (on Windows).
This command shows both global and local settings. If a setting appears twice, the local one overrides the global one. This is useful when you're troubleshooting why commits show a different name than you expected.
Setting a username if you don't have one
If git config user.name returns nothing, set one before you make your first commit. Run git config --global user.name "Your Name", replacing "Your Name" with whatever you want to appear in your commit history. You should also set your email with git config --global user.email "your.email@example.com".
The name and email you set here are public — they appear in your commit history and are visible to anyone who clones your repository. Use a name you're comfortable sharing. Many people use their real name, but you can use a nickname or pseudonym if you prefer.
Why Git needs a username separate from your online account
Git is a tool that runs on your computer. It doesn't know about GitHub, GitLab, Bitbucket, or any other service unless you tell it to connect. Your Git username is purely local metadata that Git attaches to every commit you make. Your GitHub username (or GitLab username, etc.) is a separate account on a separate server.
When you push commits to GitHub, Git sends both your local commits and your GitHub credentials. GitHub then matches your commits to your account based on the email address in the commit, not the name. This is why setting the correct email is often more important than the exact name — GitHub uses email to link commits to your profile.
Changing your username for future commits
Run git config --global user.name "New Name" to change your username going forward. This affects all new commits you make on this computer. Old commits keep the name they were made with — changing the setting doesn't rewrite history.
If you need to change the name on commits you've already made, that requires rewriting your repository history, which is complex and can cause problems if others are working on the same project. For most people, it's simpler to just use the new name for future commits and leave old ones as they are.
Frequently Asked Questions
Is my Git username the same as my GitHub username?
No. Your Git username is stored on your computer and can be anything. Your GitHub username is your account name on GitHub's website. They're completely separate. You can have a Git username of "Alice Smith" and a GitHub username of "asmith42" — they don't have to match.
Why does my commit show a different name than what I set?
Check whether you have a local username set in that specific repository. Run git config user.name inside the repository folder. If it shows a different name than your global setting, that local setting is what Git uses for commits in that folder.
Can I use an email address as my Git username?
Yes, technically you can set your username to anything, including an email address. But it's clearer to use a name for the username field and an email for the email field. Git keeps them separate for a reason.
What happens if I don't set a username before making a commit?
Git will refuse to create the commit and ask you to set user.name and user.email first. You can set them at that point, and then retry the commit.
Do I need to set my username differently on Windows, Mac, or Linux?
No. The command git config user.name works the same way on all three. The only difference is how you open your terminal — Command Prompt or PowerShell on Windows, Terminal on Mac, and your choice of terminal on Linux.