Check your Git username with a single command

Your Git username is stored in your Git configuration file on your computer. The fastest way to see it is to open your terminal or command prompt and type git config user.name, then press Enter. Git will print your username on the next line — or nothing at all if you have not set one yet.

This command reads from your local configuration, which is what Git uses when you make commits on your machine. If you have set up Git on multiple computers, each one might have a different username configured, so you need to check the one you are actually using.

If you use GitHub, GitLab, or another hosting service, your Git username on your computer may be different from your account username on that website. The command above shows only what is stored locally on your machine.

Key Takeaways

  • Type git config user.name in your terminal to see the username Git will use when you commit.
  • If nothing prints, you have not set a username yet and need to configure it before making commits.
  • Your local Git username can differ from your account name on GitHub, GitLab, or other hosting services.
  • Use git config --global user.name "Your Name" to set a username that applies to all repositories on your computer.
  • Use git config user.name "Your Name" without the --global flag to set a username for only the current repository.

Where Git stores your username

Git keeps configuration in two places: a global file that applies to all your repositories, and a local file inside each repository folder. When you commit, Git checks the local configuration first. If it does not find a username there, it uses the global one.

On Windows, the global configuration file is usually at C:\Users\YourUsername\.gitconfig. On Mac and Linux, it is at ~/.gitconfig. You can open these files in a text editor to see all your settings, but the command git config user.name is faster and more reliable.

The local configuration for a specific repository lives inside the .git folder at the root of that repository. You rarely need to look at it directly — Git commands handle it for you.

Set your username if you have not already

If git config user.name prints nothing, Git does not know who you are yet. You must set a username before you can commit. The name you choose does not have to match your real name — it is just a label that appears in your commit history.

To set a username that applies to all repositories on your computer, type:

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

Replace "Your Name" with whatever you want to appear in your commits. Then run git config user.name again to confirm it was saved.

If you want a different username for only one repository, navigate into that repository folder and type the same command without the --global flag:

git config user.name "Your Name"

This local setting overrides the global one for that repository only.

Difference between Git username and GitHub username

Your Git username is what you set on your computer with the git config command. Your GitHub username (or GitLab, Bitbucket, etc.) is your account name on that website. They do not have to match.

When you push code to GitHub, GitHub identifies you by your account credentials — your username and password, or an SSH key — not by the Git username in your commits. The Git username is just metadata that says who made the commit. You can set it to anything.

This means you could have a Git username of "Alice" but push to a GitHub account named "alice.smith". The commits will show "Alice" as the author, but GitHub will know the push came from the "alice.smith" account. This is useful if you work under a pseudonym or want your commits to show a different name than your account.

Check Git configuration on a shared computer

If you share a computer with other developers, each person should have their own Git username set. When you run git config user.name, you see only the username for the current user account on the computer, not for other users.

If you are the only person using your user account on the computer, your Git username is personal to you. If someone else logs in with a different user account, they can set their own Git username without affecting yours.

On a shared computer, it is important that each developer sets their own username so that commits are attributed correctly. If two people use the same user account on the computer, they will both appear as the same Git user, and you will not be able to tell who made which commit.

Verify your email is also configured

Git also stores an email address alongside your username. When you commit, both the name and email appear in the commit history. You can check your email with git config user.email.

If you have set a username but not an email, Git will warn you the first time you try to commit. Set your email the same way you set your username:

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

The email does not have to be real or match any account. It is just another piece of metadata in your commits. However, if you plan to push to GitHub or another service, using a real email makes it easier for those services to link commits to your account.

Frequently Asked Questions

What if git config user.name returns nothing?

You have not set a username yet. Run git config --global user.name "Your Name" to set one. After that, git config user.name will show what you entered.

Can I have different usernames for different repositories?

Yes. Set a global username with the --global flag, then navigate into a specific repository and run the same command without --global to override it for just that folder. The local setting takes priority.

Does my Git username have to match my real name?

No. Git username is just a label in your commit history. You can set it to anything — a pseudonym, a company name, or any text. It does not affect authentication or account security.

Is my Git username the same as my GitHub username?

Not necessarily. Your Git username is what you set locally on your computer. Your GitHub username is your account name on GitHub's website. They can be different, and GitHub uses your account credentials to identify you, not your Git username.

How do I change my Git username?

Run git config --global user.name "New Name" to change your global username, or run it without --global inside a repository to change it for just that folder. The new username applies to commits you make from that point forward — it does not change old commits.