Check your Git configuration with two straightforward commands

Your Git username and email are stored in your computer's Git configuration. To see what you have set up, open your terminal and run two separate commands — one for each piece of information. The commands are git config user.name and git config user.email. Each will print out what you currently have configured, or nothing if you haven't set it yet.

These settings matter because Git attaches your name and email to every commit you make. When you push code to a repository on GitHub, GitLab, or another platform, that information becomes part of the permanent record. If your email doesn't match the account you're pushing to, the platform may not recognize the commit as coming from you.

Key Takeaways

  • Run git config user.name to see your current Git username, and git config user.email to see your email.
  • If either command returns nothing, you haven't set that value yet and should configure it before making commits.
  • These settings are stored locally on your computer and can differ from your GitHub or GitLab account name.
  • Use git config --global user.name "Your Name" and git config --global user.email "your@email.com" to set them for all repositories on your machine.

The exact steps to check your configuration

Open your terminal or command prompt. On macOS or Linux, this is the Terminal app. On Windows, you can use Command Prompt, PowerShell, or Git Bash if you have it installed.

Type the first command and press Enter:

git config user.name

The terminal will print your current Git username, or print nothing if you haven't set one. Then type the second command and press Enter:

git config user.email

Again, you'll see your email or a blank line. Write down both values — you'll need them if you want to change either one, or if you're troubleshooting why commits aren't showing up under your account on GitHub or another platform.

Why Git needs your username and email

Git is a version control system that tracks who made each change to a file and when. Your username and email are the "who" part of that record. Every time you commit code, Git stamps that commit with your name and email. This creates an audit trail that shows which developer wrote which lines of code.

On platforms like GitHub, your email is also how the platform connects commits to your account. If you commit with an email that doesn't match any email on your GitHub account, the commit will appear to come from a stranger rather than from you. Your contribution graph won't fill in, and you won't get credit for the work.

The difference between local and global configuration

Git stores configuration at two levels: global and local. Global settings explore to every repository on your computer. Local settings explore only to one specific repository and override the global settings if both are set.

When you run git config user.name without any flags, Git checks the local configuration first. If nothing is set locally, it checks the global configuration. If you want to see only your global settings, add the --global flag: git config --global user.name. To see only local settings for the current repository, add the --local flag: git config --local user.name.

Most people set their username and email globally once, then leave them alone. You might set local overrides only if you work on a project that requires a different name or email — for example, if you contribute to an open-source project under a pseudonym.

What to do if your configuration is wrong

If the username or email doesn't match what you want, you can change it. To set your global username, run:

git config --global user.name "Your Actual Name"

To set your global email, run:

git config --global user.email "your.email@example.com"

Replace the text in quotes with your actual name and email. These changes take effect when ready for all new commits. Commits you've already made will keep the old name and email — changing the configuration doesn't rewrite history.

If you need to change the configuration for only one repository, navigate into that repository's folder in the terminal and run the same commands with --local instead of --global.

Checking configuration across multiple machines

Git configuration is stored on your computer, not in the cloud. If you work on multiple machines — a laptop and a desktop, for example — you'll need to set your username and email on each one separately. The configuration on your work computer doesn't automatically appear on your home computer.

This is by design: it lets you use different identities on different machines if you need to. But it also means you should check your configuration on any new machine before you make your first commit. A few seconds spent running git config user.name and git config user.email can save you from discovering later that commits were made under the wrong name.

Frequently Asked Questions

What if git config returns nothing?

If either command returns a blank line, you haven't set that value yet. You should configure both your username and email before making commits. Use git config --global user.name "Your Name" and git config --global user.email "your@email.com" to set them.

Can I use a different username and email for different projects?

Yes. Set your global username and email for everyday use, then navigate into a specific project folder and run git config --local user.name "Different Name" and git config --local user.email "different@email.com". The local settings will override the global ones only for that project.

Does my Git email have to match my GitHub email?

Your Git email doesn't have to match your GitHub username, but it should match one of the email addresses on your GitHub account. GitHub uses email to connect commits to your profile. If you commit with an email that isn't registered on your account, the commit won't show up in your contribution graph.

How do I see all my Git configuration settings at once?

Run git config --list to see all settings Git knows about. This includes your username, email, default editor, and many other options. Add --global or --local to see only global or local settings.

Will changing my Git configuration affect commits I already made?

No. Changing your configuration only affects new commits going forward. Old commits keep the name and email they were made with. If you need to change the author of past commits, that requires rewriting Git history, which is a more advanced task.