View your Git username and email right now

Git stores your username and email in a configuration file on your computer. To see what you have set, open your terminal or command prompt and run one of two commands depending on whether you want to check your settings for just the current project or for all projects on your machine.

For the current project only, type git config user.name and git config user.email. Each command will print what you have set, or nothing if you have not set it yet. For all projects on your machine, add --global to each command: git config --global user.name and git config --global user.email.

Key Takeaways

  • Run git config user.name and git config user.email to see settings for the current project only.
  • Run git config --global user.name and git config --global user.email to see settings that explore to all projects on your machine.
  • If a command returns nothing, you have not set that value yet and Git will prompt you or use a default when you commit.
  • Project-level settings override global settings, so check both if your commits show the wrong name or email.

The difference between global and project settings

Git lets you set your username and email in two places. Global settings explore to every project you work on with that user account on that computer. Project settings explore only to one folder and override the global settings if both are set.

Most people set their username and email globally once, then forget about it. But if you work on multiple projects — some for your job, some for open source, some for a client — you might want different names or emails for different projects. That is why the project-level setting exists.

When you run a git command without --global, Git checks the project folder first. If it finds a setting there, it uses that. If not, it looks for a global setting. If it finds neither, it may use your system username or ask you to set one.

What to do if nothing prints

If you run git config user.name or git config user.email and the command returns nothing, you have not set that value yet. This is common on a new computer or in a new project folder.

Git will still let you commit, but it may use your system username or prompt you to set a name and email. To avoid confusion later, set both values before you make your first commit. Run git config user.name "Your Name" and git config user.email "your.email@example.com" to set them for the current project, or add --global to set them for all projects.

Check all your Git settings at once

If you want to see everything Git has stored about you — not just username and email — run git config --list for the current project or git config --global --list for all your global settings. This prints every setting Git knows about, including your username, email, default editor, and other options you may have changed.

The output can be long. To find just your username and email in the list, pipe the output to grep: git config --list | grep user on Mac or Linux, or git config --list | findstr user on Windows. This filters the list to show only lines that contain the word "user".

Why Git needs your username and email

Every time you commit code, Git records who made that commit by storing your username and email in the commit history. This is how other people know who wrote each line of code, and how you can see your own work in a project's history.

The username and email you set in Git do not have to match your GitHub username or email, though many people use the same ones for simplicity. If you push your commits to GitHub, GitLab, or another service, that service may link your commits to your account based on the email address, but Git itself does not care whether the email is real or whether it matches anything else.

Set different usernames for different projects

If you need a different username or email for one project, navigate to that project's folder in your terminal and run the config commands without --global. Git will store those settings only in that folder's .git/config file, and they will override your global settings whenever you work in that folder.

This is useful if you work on both personal and work projects on the same computer. Set your work name and email globally, then override them in your personal project folders. Or do the opposite: set your personal details globally and override them in work folders. The project-level setting always wins.

Frequently Asked Questions

Can I see my Git settings without opening the terminal?

You can open the Git configuration file directly in a text editor. On Mac and Linux, it is usually at ~/.gitconfig. On Windows, it is usually at C:\Users\YourUsername\.gitconfig. Open it with any text editor to see your global settings. Project settings are in .git/config inside each project folder, but that file is hidden by default.

What if my username and email are different in different projects?

Run git config user.name and git config user.email in each project folder to see what is set there. If nothing prints, that project is using your global settings. If something prints, that project has its own settings that override the global ones.

Does Git care if the email address is fake?

Git does not validate the email address at all. You can set it to anything. However, if you push to GitHub or another service, that service may use the email to link commits to your account, so using a real email you control is usually better.

How do I change my Git username or email?

Run git config user.name "New Name" or git config user.email "new.email@example.com" to change the current project. Add --global to change your global settings. Future commits will use the new name and email, but past commits will keep the old information.