Check your Git username with a single command
Your Git username is stored in your local Git configuration file. To see it, open your terminal or command prompt and type git config user.name. The output will show the name you set when you first configured Git on that computer.
If nothing appears, Git has not been configured yet on this machine. That does not mean you do not have a username — it means you need to set one before you can commit changes. The steps below cover both checking what you have and setting a new username if needed.
Key Takeaways
- Run git config user.name in your terminal to see the username Git will use for your commits on this computer.
- The username stored locally on your machine may differ from your GitHub, GitLab, or Bitbucket account name.
- If no username appears, you can set one with git config user.name "Your Name" for just the current project, or add --global to set it for all projects on this machine.
- Your Git username is separate from your email address, though both are stored in the same configuration file.
Check your username on Windows
Open Command Prompt or PowerShell. Type git config user.name and press Enter. If Git is installed and configured, your username will appear on the next line. If you see an error saying Git is not recognized, Git may not be installed or not added to your system path.
You can also check your email address at the same time by typing git config user.email. Both values are stored together in your Git configuration, so checking one often leads to checking the other.
Check your username on Mac or Linux
Open Terminal. Type git config user.name and press Enter. Your username will display if it has been set. On Mac, you can also open Terminal from Applications > Utilities, or press Command + Space, type Terminal, and press Enter.
If you want to see all your Git configuration settings at once, type git config --list. This shows your username, email, default editor, and other settings Git knows about on this machine.
Understand local versus global configuration
Git stores configuration at two levels: local (for a single project folder) and global (for all projects on your computer). When you run git config user.name without any flags, Git checks the local setting first. If no local setting exists, it falls back to the global one.
If you have set different usernames for different projects, the local setting takes priority. To see only your global username, type git config --global user.name. To see only the local setting for the current project, type git config --local user.name.
Set a new username if none exists
If git config user.name returns nothing, you need to set a username before you can commit. Type git config user.name "Your Name", replacing "Your Name" with the name you want Git to use. This sets the username for the current project only.
To set a username that applies to all projects on this computer, add the --global flag: git config --global user.name "Your Name". You only need to do this once per machine. After that, every new project will use this username unless you override it with a local setting.
Know the difference between Git username and account username
Your Git username is the name stored in your local Git configuration. Your GitHub username, GitLab username, or Bitbucket username is different — it is the account name you use to log in to those websites. They do not have to match.
For example, you might set your Git username to "Jane Smith" but have a GitHub account named "jsmith42". When you push code to GitHub, Git uses your account credentials (username and password, or SSH key) to authenticate, not the Git username. The Git username only appears in the commit history as the author of the changes.
Verify your username is correct before committing
Before you make your first commit in a new project, run git config user.name to confirm the username is what you want. Commits are permanent — once you push them to a shared repository, the author name is part of the history. If you set the wrong name, future commits will show the correct name, but past commits will still show the old one.
If you need to change the author name on commits you have already made, that requires rewriting history, which is complex and can cause problems if others are working from the same repository. It is easier to get the name right from the start.
Frequently Asked Questions
Can I have different Git usernames for different projects?
Yes. Set a global username with git config --global user.name, then override it in specific projects by running git config user.name "Different Name" inside that project folder. Git will use the local setting for that project and the global setting for all others.
What if I do not remember my GitHub username but I need my Git username?
Your Git username and your GitHub username are separate. Run git config user.name to see your Git username. To find your GitHub username, log into GitHub.com and look at the top right corner of the page — your username appears in the dropdown menu next to your profile picture.
Does my Git username have to be my real name?
No. Git username can be anything — your real name, a nickname, a pseudonym, or a company name. It is purely for identifying who made each commit in the project history. Choose whatever name you want to appear as the author of your code.
Why does git config user.name show nothing even though I set it?
You may be in a project folder that has its own local configuration, and that local setting is empty. Try git config --global user.name to check your global setting. Or you may be outside any Git project folder — navigate into a folder that contains a .git subfolder and try again.