Check your username with the git config command
Open Git Bash and type git config user.name, then press Enter. Git will display the username you have set for commits on your machine. If nothing appears, you have not yet configured a username — Git needs one before you can commit code.
This command shows only the username stored on your local machine. If you use multiple machines or accounts, each one may have a different username configured. The username you see here is what will appear as the author on every commit you make from this installation of Git.
Key Takeaways
- Type git config user.name in Git Bash to see the username Git will use for your commits.
- If the command returns nothing, you have not yet set a username and need to configure one before committing.
- The username shown is local to your machine — other computers may have different usernames configured.
- You can set a username with git config user.name "Your Name" if you need to change it.
- Use git config --global user.name to check or set a username that applies to all your Git projects on that machine.
The difference between local and global configuration
Git stores usernames in two places: local (for one project folder) and global (for all projects on your machine). When you type git config user.name, you see the local setting if one exists. If no local setting exists, Git falls back to the global one.
To check your global username instead, type git config --global user.name. This shows the username that applies to every project unless you override it with a local setting. Most people set a global username once and use it everywhere, but teams sometimes use local usernames for specific projects.
What to do if no username appears
If Git Bash returns nothing or an error, you have not configured a username yet. Set one by typing git config user.name "Your Name" (replace "Your Name" with the name you want to appear on commits). Use quotes around the name if it contains spaces.
To set a global username that applies to all your projects, add the --global flag: git config --global user.name "Your Name". After you run this command, git config user.name will show your new username. You only need to do this once per machine.
Checking your email address at the same time
Git also stores an email address alongside your username. Type git config user.email to see what email is configured. This email appears in commit history and on platforms like GitHub, so make sure it matches the account you use there.
If you need to change your email, use git config user.email "your.email@example.com" for the local project or git config --global user.email "your.email@example.com" for all projects. The email does not have to be real, but using a genuine one makes it easier for others to contact you about your work.
Why Git needs a username for every commit
Git records the username and email with every commit you make. This creates a permanent record of who wrote each line of code and when. On platforms like GitHub or GitLab, this username may link to your account profile, but Git itself does not care whether the name is real or matches any account — it just stores what you tell it to store.
If you work on a team, the username helps others know who made a change. If you switch machines or reinstall Git, you will need to set the username again on the new installation. Many people set a global username right after installing Git to avoid having to do it for every project.
Viewing all your Git configuration at once
To see every setting Git has stored for you, type git config --list. This shows your username, email, and dozens of other settings. The output can be long, but you can search it by piping to grep: git config --list | grep user will show only the lines containing "user".
If you want to see only global settings, type git config --global --list. This is useful when you have both local and global usernames and want to know which one is which. Local settings override global ones, so if both exist, the local username is what Git will use for commits in that folder.
Frequently Asked Questions
Can I have different usernames for different projects?
Yes. Set a global username with git config --global user.name, then navigate to a specific project folder and set a local username with git config user.name (without the --global flag). Git will use the local username for that project and the global one for all others.
Does my Git username have to match my GitHub username?
No. Your Git username is just a label Git stores with commits. Your GitHub username is your account name on GitHub. They can be different, but using the same name makes it easier for others to connect your commits to your GitHub profile. GitHub links commits based on email address, not username.
What if I see a username I did not set?
Someone else may have configured Git on your machine, or Git may have picked up a default from your system. You can change it anytime with git config user.name "Your Name". If you want to know where a setting came from, check your global config file at ~/.gitconfig or your local config at .git/config inside your project folder.
Do I need to restart Git Bash after changing my username?
No. The change takes effect when ready. Your next commit will use the new username. You can verify the change right away by typing git config user.name again.