Check your Git username and email from the command line

Your Git username and email are stored in your Git configuration file on your computer. To see what you have set, open your terminal or command prompt and run two commands — one for each piece of information. The commands work the same way on Windows, Mac, and Linux.

Type git config user.name and press Enter. Git will display the username you have configured. Then type git config user.email and press Enter to see your email. If you have never set either one, Git will return nothing — no error message, just an empty line.

These commands show only your local settings. If you want to see all your Git configuration at once, including settings you may have forgotten about, type git config --list and press Enter. This displays every setting Git knows about on your machine, including user.name and user.email near the top of the list.

Key Takeaways

  • Run git config user.name to see your username and git config user.email to see your email address.
  • An empty response means you have not set that information yet, and you will need to configure it before making commits.
  • Use git config --list to see all your Git settings at once, which is useful if you have multiple configurations.
  • These commands show your local machine settings; if you work on multiple computers, each one may have different settings.

Where Git stores your username and email

Git keeps your configuration in a hidden file called .gitconfig in your home directory. On Mac and Linux, this is in ~/.gitconfig. On Windows, it is usually in C:\Users\[YourUsername]\.gitconfig. You can open this file directly in a text editor if you want to see or change your settings manually, but using the command line is faster and safer.

When you make a commit, Git reads this file and stamps your username and email onto that commit. Everyone who pulls your code later will see that information. This is why it matters that the email and name are correct — they become part of your commit history permanently.

The difference between local and global settings

Git lets you set your username and email in two ways: globally (for all projects on your machine) or locally (for just one project). When you run git config user.name without any flags, Git checks the local setting first. If it does not find one, it falls back to your global setting.

If you work on projects for different organizations or use different names for different purposes, you might have set a global username but a different local one for a specific project. The commands above will show you the local setting if one exists. To see your global setting specifically, add --global to the command: git config --global user.name.

What to do if your username or email is wrong

If the information Git shows you is incorrect, you can change it. To update your local settings for just the current project, type git config user.name "Your Name" and git config user.email "your.email@example.com". Replace the text in quotes with your correct information. These changes affect only the current project.

To change your global settings so all future projects use the correct information, add --global to each command: git config --global user.name "Your Name" and git config --global user.email "your.email@example.com". After you make these changes, run the original check commands again to confirm the update took effect.

Why Git needs your username and email

Git uses your username and email to identify who made each commit. When you push code to a repository on GitHub, GitLab, or another platform, that platform matches your Git email to your account on their service. If the email does not match, the commit may show as coming from an unknown user instead of being linked to your profile.

This is also why you should use a real email address — one you actually check. If you use a fake or outdated email, you may not receive notifications about comments on your commits, and your contributions may not appear on your public profile the way you expect.

Checking your username and email on different machines

If you work on multiple computers — a laptop, a desktop, and a work machine — each one has its own Git configuration. You might have set your username on your personal laptop but never configured it on your work computer. Before you start a new project on a different machine, run the check commands to see what is already set.

This is especially important if you share a computer with other developers. Each person should have their own user account on the machine, and each account should have its own Git configuration. If you are all using the same user account, you will all be committing under the same name and email, which makes it impossible to tell who actually wrote the code.

Frequently Asked Questions

What if git config returns nothing?

An empty response means you have not set that configuration yet. You need to set both your username and email before you can make commits. Use git config user.name "Your Name" and git config user.email "your.email@example.com" to add them.

Can I use a different email for different projects?

Yes. Set a global email with --global, then navigate to a specific project folder and run git config user.email "different.email@example.com" without the --global flag. That project will use the local email instead of the global one.

Does changing my Git email affect past commits?

No. Changing your Git configuration only affects commits you make from that point forward. Commits you have already made keep the username and email that were set when you made them. You cannot change the author of a past commit without rewriting history, which is complex and not recommended for shared repositories.

Why does my GitHub profile not show my commits?

GitHub links commits to your account by matching the email in the commit to an email address on your GitHub account. If your Git email does not match any email in your GitHub settings, the commit will not appear on your profile. Check that your Git email matches one of the emails listed under your GitHub account settings.