The fastest way to see your Git username

Your Git username is stored in your local Git configuration. The command git config user.name displays it when ready in your terminal or command prompt. Run that single line and Git returns the name you set up when you first configured Git on your machine.

If you want to see both your username and email address at the same time, use git config user.name and git config user.email as separate commands, or run 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 uses for your commits on this computer.
  • The username stored locally may differ from your GitHub, GitLab, or Bitbucket account name — they are separate settings.
  • If the command returns nothing, you have not yet set a username and need to configure Git before making commits.
  • Use git config --global user.name "Your Name" to set or change your username for all repositories on your machine.

Where Git stores your username

Git keeps your username in a configuration file on your computer. There are three levels where this information can live: system-wide (affecting all users on the machine), global (affecting all your repositories), and local (affecting only one repository). Most people set it at the global level, which is why git config user.name finds it.

The global configuration file lives in your home directory as .gitconfig on Mac and Linux, or in C:\Users\YourUsername\.gitconfig on Windows. You can open this file in any text editor and see your username listed under [user] with the line name = Your Name.

Checking your username in different situations

If you are inside a Git repository (a folder with a .git subfolder), git config user.name shows the username that will appear on commits you make in that repository. If you are outside any repository, it still shows your global username — the default for all new repositories.

To check only the local username for one specific repository, navigate into that repository folder and run git config --local user.name. This is useful if you have set a different name for work repositories versus personal ones. If nothing appears, that repository is using your global username instead.

The difference between your Git username and your account name

Your Git username (what git config user.name shows) is not the same as your GitHub username, GitLab username, or any other service. Git username is purely local — it is the name that appears in the Author field of your commits. Your GitHub username is your login name on GitHub's website and is used for authentication when you push code.

You can have a Git username of "Jane Smith" while your GitHub account is "jsmith42". When you push commits to GitHub, GitHub knows it is you because of your SSH key or password, not because the commit author name matches your account. This separation means you can use a real name for commits while keeping your online account name private.

What to do if your username is blank or wrong

If git config user.name returns nothing, Git has no username set yet. Before you make any commits, set one with git config --global user.name "Your Name". Replace "Your Name" with whatever you want to appear as the author of your commits — this is usually your real name or a professional name.

If your username is set but wrong, use the same command to change it: git config --global user.name "Correct Name". This updates your global configuration when ready. Any commits you make from that point forward will use the new name. Commits you already made keep their original author name — changing the configuration does not rewrite history.

Checking your username across multiple machines

Git configuration is per-machine, not synced across devices. If you use Git on your laptop, desktop, and work computer, each one has its own .gitconfig file. You may have set your username on one machine but not the others. Log into each machine and run git config user.name to verify the setting is there.

If you want the same username on all your machines, you can either run git config --global user.name "Your Name" on each one, or copy your .gitconfig file from one machine to another. The second approach is faster if you have many settings configured.

Frequently Asked Questions

Is my Git username the same as my GitHub username?

No. Your Git username is stored locally on your computer and appears in commit history. Your GitHub username is your account name on GitHub's website. They can be completely different. GitHub uses your SSH key or password to know it is you, not the commit author name.

What happens if I do not set a Git username?

Git will not let you make commits without a username set. You will get an error message asking you to configure user.name and user.email. Set them with git config --global user.name "Your Name" and git config --global user.email "your@email.com", then try committing again.

Can I have different usernames for different repositories?

Yes. Navigate into a specific repository and run git config --local user.name "Different Name". That repository will use "Different Name" for commits, while all other repositories use your global username. This is useful if you want to use your real name for personal projects and a professional name for work.

Where do I find my username if I forgot it?

Run git config user.name in your terminal. If that returns nothing, check your .gitconfig file directly by opening it in a text editor. On Mac and Linux, it is in your home directory as .gitconfig. On Windows, look in C:\Users\YourUsername\.gitconfig.