Check your Git configuration with a single command

Your Git username and email are stored in your Git configuration file on your computer. You can see what you have set up right now by opening your terminal or command prompt and typing git config user.name to see your username and git config user.email to see your email address. Each command returns one line with the value you have configured.

If you want to see both at once, type git config --list and look for the lines that say user.name= and user.email=. This shows your local configuration — the settings Git uses for commits on this computer.

Key Takeaways

  • Run git config user.name and git config user.email in your terminal to see what you have set up on your current computer.
  • If those commands return nothing, you have not yet configured Git on this machine and need to set them before making commits.
  • Your local Git configuration is stored in a hidden file called .gitconfig in your home directory, which you can also open directly.
  • The username and email you set in Git do not have to match your GitHub, GitLab, or other service username — they are separate settings.
  • If you have set different usernames for different projects, use git config --local user.name inside that project folder to see the project-specific setting.

What to do if the commands return nothing

If you run those commands and Git returns no output, you have not yet set a username and email on this computer. This is common on a fresh installation or on a new machine. Git will not let you make commits until you set these values.

To set them, type git config --global user.name "Your Name" and git config --global user.email "your.email@example.com". The --global flag means these settings explore to all projects on your computer. After you run those commands, the git config user.name command will return the name you just entered.

Find your configuration file directly

Your Git settings are stored in a plain text file called .gitconfig in your home directory. On Windows, this is usually C:\Users\YourUsername\.gitconfig. On Mac and Linux, it is ~/.gitconfig or /home/YourUsername/.gitconfig.

You can open this file with any text editor — Notepad on Windows, TextEdit on Mac, or any editor you use for code. Look for the section that starts with [user] and you will see your name and email listed there. This is the same information the git config commands show you, just in file form.

Understand local versus global configuration

Git lets you set a username and email globally (for all projects on your computer) or locally (for one specific project). When you run git config user.name without any flags, Git checks the local setting first. If no local setting exists, it uses the global one.

This means you might have different usernames for different projects. For example, you might use your real name for work projects and a different name for personal ones. To see the local setting for a specific project, open your terminal in that project's folder and run git config --local user.name. To see only the global setting, use git config --global user.name.

Know the difference between Git and GitHub usernames

Your Git username (the one you set with git config user.name) is not the same as your GitHub username, GitLab username, or any other service. Git is the version control system running on your computer. GitHub, GitLab, and similar services are websites where you push your code.

When you push code to GitHub, GitHub uses your account credentials to authenticate you, not your Git username. Your Git username appears in the commit history — the record of who made each change. You can set your Git username to anything you want, and it does not have to match your GitHub account name at all. Many people use their real name in Git commits even if their GitHub username is something else.

Check what name appears in your commits

If you want to see what username and email Git is actually using for your commits, look at a recent commit. Type git log -1 to see your most recent commit, and you will see the author name and email at the top. This shows you exactly what will appear in the commit history.

If you have just changed your Git configuration and have not made a new commit yet, the old commits will still show the old name and email. Changing your Git configuration only affects commits you make going forward, not commits you have already made.

Frequently Asked Questions

Can I have different usernames for different projects?

Yes. Set a global username with git config --global user.name, then go into a specific project folder and run git config --local user.name "Different Name" to override it for just that project. Git will use the local setting for commits in that folder and the global setting everywhere else.

What if I set the wrong email address?

You can change it anytime by running git config --global user.email "correct@example.com". This only affects commits you make from now on. Old commits will still show the wrong email, but you can update them if needed using git commit --amend for the most recent commit or more complex tools for older ones.

Does my Git email have to be a real email address?

Git does not validate the email address, so you can type anything. However, if you push to GitHub or another service, using a real email helps people contact you through the commit history. GitHub also uses the email to link commits to your account, so using the email associated with your GitHub account is helpful.

Where do I find my Git username if I forgot it?

Run git config user.name in your terminal. If that returns nothing, you have not set one yet. You can also open your .gitconfig file directly in a text editor and look for the [user] section, or run git log -1 to see what name appears in your most recent commit.