The fastest way to see your Git username
Your local Git username is stored in your computer's Git configuration file. The quickest way to see it is to open your terminal or command prompt and run a single command: git config user.name. This returns exactly what name Git will attach to your commits on this machine.
If nothing appears after you run that command, Git has no username set yet on your local system. This is common on a fresh installation. The absence of output means you will need to set one before you can commit changes.
You can also see both your username and email together by running git config --list, which displays all your Git settings at once. Look for the line that starts with user.name.
Key Takeaways
- Run git config user.name in your terminal to see your local Git username when ready.
- If no output appears, you have not set a username yet on this machine.
- The git config --list command shows all your Git settings, including username and email.
- Your local username is separate from your GitHub, GitLab, or Bitbucket account name — they do not have to match.
- Different machines can have different usernames, even if you use the same Git hosting service on all of them.
Where Git stores your username
Git keeps your username in a configuration file on your computer. On Mac and Linux, this file lives at ~/.gitconfig in your home directory. On Windows, it is usually at C:\Users\YourUsername\.gitconfig.
You can open this file directly in a text editor to see your settings, but the command line is faster and less error-prone. If you do open the file, look for a section that looks like this:
[user] name = Your Name Here email = your.email@example.com
The name you see there is exactly what Git will use when you commit. If the [user] section does not exist in the file, your username is not set.
Checking username for a specific repository
Git has two levels of configuration: global (applies to all your repositories on this machine) and local (applies only to one specific repository). Most people use the global setting, but some projects override it with their own local username.
To check the global username, run git config --global user.name. To check if a specific repository has its own username, navigate into that repository folder and run git config user.name without the --global flag.
If the local repository has its own username set, that command will show it. If it does not, the command returns nothing — meaning that repository will use your global username instead.
What to do if your username is not set
If git config user.name returns nothing, you need to set a username before you can 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 at the same time: git config --global user.email "your.email@example.com". Both the name and email are recorded with every commit you make.
After you run these commands, verify they worked by running git config user.name and git config user.email again. You should see the values you just entered.
The difference between your local username and your online account
Your local Git username is what appears in your commit history on your machine. Your GitHub, GitLab, or Bitbucket username is your account name on those websites. These do not have to match.
For example, your local username could be "Jane Smith" while your GitHub username is "jsmith42". When you push commits to GitHub, the commit still shows "Jane Smith" as the author, but GitHub knows it came from the jsmith42 account because of your SSH key or credentials.
This separation is intentional — it lets you use a professional name in your commit history while keeping any username you want on the hosting service.
Changing your username if it is wrong
If you see a username you did not intend, you can change it when ready. Run git config --global user.name "New Name" with the name you want to use going forward.
This change affects only commits you make from this point on. Commits you already made will still show the old name — changing the configuration does not rewrite history. If you need to fix the author name on past commits, that requires a more complex process that most people do not need.
If you want to use a different username for just one repository, navigate into that folder and run git config user.name "Name For This Project" without the --global flag. That repository will use the local setting instead of your global one.
Frequently Asked Questions
Can I have different usernames on different machines?
Yes. Each machine has its own Git configuration file. You can set one username on your work computer and a different one on your personal laptop. When you push to the same repository from both machines, the commits will show different author names.
Does my Git username have to match my GitHub username?
No. Your Git username is what appears in commit history. Your GitHub username is your account name on GitHub. They are separate and do not need to match. GitHub knows which account pushed the commit based on your SSH key or login credentials, not the author name in the commit.
What if git config user.name shows nothing?
Git has no username set on this machine yet. Run git config --global user.name "Your Name" to set one. After that, git config user.name will show the name you entered.
Can I see the username without using the command line?
You can open the .gitconfig file directly in a text editor, but the command line is faster. On Mac and Linux, the file is at ~/.gitconfig. On Windows, it is at C:\Users\YourUsername\.gitconfig. Look for the [user] section and the name line.
Does changing my Git username affect old commits?
No. Changing your Git configuration only affects new commits you make from that point forward. Commits you already made will keep the author name they had when you made them. Rewriting the author name on past commits is possible but requires special commands and is rarely necessary.