Check your username from the command line

The fastest way to see your Git username is to open your terminal or command prompt and run a single command. This works whether you use Git on Windows, Mac, or Linux.

Type git config user.name and press Enter. Git will print the name you have set for commits on your current machine. If nothing appears, you have not yet configured a username on this computer — which means your next commit will fail with an error message.

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

Key Takeaways

  • Run git config user.name in your terminal to see the username Git will use for your commits.
  • If the command returns nothing, you have not yet set a username on this machine and need to configure one before making commits.
  • The username stored locally on your computer may differ from your account name on GitHub, GitLab, or another Git hosting service.
  • Use git config --list to view all your Git settings, including username, email, and other configuration details.

Understand the difference between local and remote usernames

Your local Git username — the one you just checked — is what appears in the author field of every commit you make on your current computer. This is separate from your account username on GitHub, GitLab, Bitbucket, or any other Git hosting platform.

You might have set your local username to "Jane Smith" but your GitHub account might be "janesmith42". When you push commits to GitHub, Git uses your account credentials (usually a personal access token or SSH key) to authenticate, not your local username. The local username is purely for the commit history.

If you want to know your username on a specific hosting service, you will need to log into that service directly. On GitHub, click your profile icon in the top right and select "Settings" — your username appears at the top of the page.

Set or change your username if it is missing or wrong

If git config user.name returned nothing, or if the name shown is not what you want, you can set it right now. Run git config user.name "Your Name", replacing "Your Name" with whatever you want to appear in your commit history.

This command sets your username for the current repository only. If you want the same username for all repositories on this machine, add the --global flag: git config --global user.name "Your Name". The global setting becomes the default for every new repository you clone or create on this computer, though you can override it per repository if needed.

After you set your username, run git config user.name again to confirm the change took effect. Any commits you make from this point forward will use the new name.

Check your username in a specific repository

If you work across multiple machines or multiple repositories, you might have set different usernames in different places. To see what username is configured for one specific repository, navigate into that repository folder and run git config user.name without the --global flag.

Git checks for settings in this order: first the repository itself, then your user-level settings, then your system-level settings. If a repository has its own username set, that is what Git will use for commits in that folder, even if you have a different global username.

This is useful when you work on both personal projects and work projects from the same machine. You can set a global username for personal use and then override it in your work repositories with your company email and name.

View your Git configuration file directly

If you prefer to see all your settings in one place, you can open your Git configuration file in a text editor. On Mac and Linux, this file is usually located at ~/.gitconfig in your home directory. On Windows, it is typically at C:\Users\YourUsername\.gitconfig.

Open the file with any text editor — Notepad, VS Code, or your preferred editor — and look for the [user] section. Under that heading, you will see lines like name = Your Name and email = your.email@example.com. You can edit these directly and save the file, and Git will read the changes when ready.

This approach is helpful if you want to change multiple settings at once or if you prefer to see your entire configuration in context. However, using the git config command is safer for most people because it handles formatting and escaping automatically.

Troubleshoot when your username does not appear

If git config user.name returns nothing, Git is not finding a username in any of its configuration locations. This usually means you have never set one on this machine, or you installed Git fresh and skipped the setup step.

The solution is to set a username using git config --global user.name "Your Name". After you run this command, git config user.name will return the name you just set. You should also set an email address with git config --global user.email "your.email@example.com", because Git requires both before you can make a commit.

If you have already set a username but the command still returns nothing, check whether you are in a folder that is actually a Git repository. Run git status to confirm. If you see "fatal: not a git repository", navigate into a folder that contains a .git subfolder and try again.

Frequently Asked Questions

Is my Git username the same as my GitHub username?

Not necessarily. Your Git username is a local setting on your computer that appears in commit history. Your GitHub username is your account name on GitHub's website. You can set your local Git username to anything — it does not have to match your GitHub account. However, many people set them the same for clarity.

Can I have different usernames in different repositories?

Yes. Set a global username with git config --global user.name, then override it in specific repositories by running git config user.name (without --global) inside that repository folder. Git will use the repository-level setting for commits in that folder only.

What happens if I do not set a username before making a commit?

Git will refuse to create a commit and will show an error message telling you to configure user.name and user.email. You must set both before any commit can be recorded. The error message includes the exact commands you need to run.

Can I change my username after I have already made commits?

Yes, you can change your username at any time. Future commits will use the new name. However, past commits will keep the old username in their history — changing your current username does not rewrite old commits. If you need to change the author on past commits, that requires more advanced Git operations like interactive rebase.

Where does Git store my username?

Git stores your username in a configuration file. The global setting is in ~/.gitconfig (Mac and Linux) or C:\Users\YourUsername\.gitconfig (Windows). Repository-level settings are stored in .git/config inside each repository folder. You can view or edit these files directly with a text editor.