The fastest way to see your Git username

Open your terminal or command prompt and type git config user.name. Press Enter. If you have set a username, it will print on the next line. If nothing prints, you have not set one yet on this computer.

That single command checks the username Git will attach to every commit you make from this machine. It does not tell you your GitHub username or any online account — it is the local name stored in Git's configuration file.

If you want to see both your username and email address at once, type git config user.name and git config user.email as two separate commands, or use git config --list to see all your Git settings at once.

Key Takeaways

  • Type git config user.name in your terminal to see the username Git will use for your commits on this computer.
  • If nothing prints, you have not set a username yet and should set one before making commits.
  • The username Git stores locally is separate from your GitHub account username or any other online service.
  • Use git config --list to see all your Git settings, including username, email, and other configuration options.

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 do not need to open this file to check your username — the git config command reads it for you. But if you want to see the raw file and verify everything Git knows about you, you can open it in any text editor. The file is plain text and shows your name, email, and other settings you have configured.

Checking username at different scope levels

Git stores configuration at three different levels: system-wide (all users on the computer), global (your user account), and local (just this one repository). When you type git config user.name, Git checks all three and shows you the one that applies.

If you want to see only your global settings, type git config --global user.name. If you want to see only the settings for the current repository, type git config --local user.name. Most people set their username at the global level so it applies to every project they work on.

If you have set a username at both global and local levels, the local one takes priority. This is useful if you work on projects for different organizations and want to use different names for commits in each one.

What to do if your username is not set

If git config user.name prints nothing, Git does not have a username configured yet. Before you make your first commit, you need to set one. Type git config --global user.name "Your Name", replacing "Your Name" with the name you want to appear in your commit history.

You should also set your email address so Git has both pieces of information. Type git config --global user.email "your.email@example.com". These two commands configure Git for your entire user account, so you only need to run them once per computer.

After you set them, run git config user.name and git config user.email again to confirm the values were saved correctly.

Checking username in a specific repository

If you are inside a Git repository and want to know what username will be used for commits in that specific folder, type git config user.name from within the repository directory. If the repository has its own local configuration, that is what will print. If not, Git will show you the global username instead.

This matters because some teams or organizations set up repositories with their own local usernames. You might be working on a personal project with your own name, but when you switch to a work repository, it might be configured to use your work email and a different name. Checking from inside the repository folder tells you which one applies.

Verifying your username before making commits

Before you make your first commit in a new repository, it is a good idea to run git config user.name and git config user.email to confirm what Git will record. Commits are permanent in your history, and the name and email attached to them cannot be changed after you push to a shared repository.

If you see a username you do not recognize or an email address that is wrong, stop and fix it before committing. Use git config --global user.name "Correct Name" to update the global setting, or git config --local user.name "Correct Name" if you only want to change it for the current repository.

Frequently Asked Questions

Is my Git username the same as my GitHub username?

No. Your Git username is stored on your computer and is what appears in your commit history. Your GitHub username is your account name on GitHub's website. They can be different. When you push commits to GitHub, both names appear — the Git username in the commit itself, and your GitHub username as the account that pushed it.

Can I have different usernames for different projects?

Yes. Set a global username with git config --global user.name, then navigate into a specific repository and use git config --local user.name "Different Name" to override it just for that project. The local setting takes priority when you commit in that folder.

What happens if I commit without setting a username?

Git will refuse to create a commit and will print an error message telling you to set user.name and user.email. You cannot commit until both are configured. This prevents commits with missing or invalid author information.

How do I change my Git username?

Type git config --global user.name "New Name" to change your global username. This only affects commits you make from this point forward. Commits you already made will keep the old name. If you need to change the author on past commits, that requires a more complex process called rebasing.

Can I see the username for commits I already made?

Yes. Type git log to see your commit history, including the author name and email for each commit. Type git log --oneline for a shorter view, or git show to see details of a specific commit.