The three places your Git username lives

Your Git username is stored in three different places depending on how you set it up and what you're trying to do. The most common one is your local Git configuration, which is what Git uses when you commit code on your machine. You can also have a username in your global configuration, which applies to every repository on your computer, and a separate username on whatever Git hosting service you use — like GitHub, GitLab, or Bitbucket.

Most people confuse these three because they often have the same value, but they're stored separately and can be different. Knowing which one you're looking for saves time when something isn't working the way you expect.

Key Takeaways

  • Your local Git username is stored in the .git/config file inside each repository and is what Git uses when you commit.
  • Your global Git username is stored in your home directory and applies to all repositories unless a local setting overrides it.
  • Your Git hosting username (GitHub, GitLab, etc.) is separate from your local Git configuration and is what appears on your profile page.
  • The command git config user.name shows your local username; add --global to see your global setting instead.
  • If no username is set, Git will ask you to configure one before you can commit, or you'll see an error message with instructions.

Check your local repository username

Your local username is the one Git uses when you make commits in a specific folder. To see it, open your terminal or command prompt, navigate into the repository folder, and type:

git config user.name

Git will print your username on the next line. If nothing prints, you haven't set a local username yet — Git will fall back to your global setting, or ask you to set one when you try to commit.

If you want to see all your local settings at once (including email), type git config --list and look for the lines that start with user.name and user.email.

Check your global username

Your global username applies to every repository on your machine unless you override it with a local setting. To see it, type:

git config --global user.name

Again, Git prints your username if one exists. If nothing prints, you haven't set a global username. This is common if you set up Git for just one project and configured it locally instead.

To see all your global settings, type git config --global --list. This shows everything Git knows about you across all repositories.

Find your username on GitHub, GitLab, or Bitbucket

Your username on a Git hosting service is different from your local Git configuration. It's the name that appears in your profile URL and on your account page. To find it:

On GitHub: Log in, click your profile picture in the top right, and select "Your profile". Your username appears under your display name at the top of the page, and it's also in the URL: github.com/your-username.

On GitLab: Log in, click your profile picture, and select "Profile". Your username is shown under your name and in the URL: gitlab.com/your-username.

On Bitbucket: Log in, click your profile picture, and select "Personal settings". Your username is displayed on the page and in the URL: bitbucket.org/your-username.

This username is what you use when cloning repositories with SSH or HTTPS, and it's what appears on commits you push to the service — but only if your local Git username matches the account you're pushing from.

What to do if you see nothing

If the commands above print nothing, you haven't set a Git username yet. This is normal for a fresh installation. When you try to commit, Git will either ask you to set one or show an error message with instructions.

To set your local username for the current repository, type:

git config user.name "Your Name"

To set your global username for all repositories, type:

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

Replace "Your Name" with whatever name you want to appear in your commits. This doesn't have to match your GitHub username or your real name — it's just what shows up in the commit history.

Why your username matters

Git uses your configured username to stamp every commit you make. When someone looks at the commit history, they see your username next to the date and message. On GitHub and similar services, if your local username matches your account username, your commits are linked to your profile and show up in your contribution graph.

If your local username doesn't match your hosting service username, your commits will still go through, but they won't be linked to your account. This is why some people see commits from "John Doe" in the history even though the account is "jdoe" — the local Git configuration and the hosting account are different.

Frequently Asked Questions

Can I have different usernames for different repositories?

Yes. Your local configuration overrides your global setting, so you can set a different username in each repository folder. This is useful if you work on personal projects and work projects with different names or email addresses. Set the local username with git config user.name "Name" (without --global) inside the repository folder.

Is my Git username the same as my GitHub username?

Not necessarily. Your Git username is what you configure locally on your machine; your GitHub username is your account name on GitHub. They often match, but they don't have to. If they don't match, your commits will still push to GitHub, but they won't be linked to your profile.

What if I set the wrong username and want to change it?

Type git config user.name "New Name" to change your local username, or git config --global user.name "New Name" to change your global one. This only affects future commits — it won't change the username on commits you've already made.

How do I see my username and email together?

Type git config --list to see your local settings or git config --global --list to see your global settings. Look for the lines starting with user.name and user.email. Both are usually set at the same time.

Why does Git ask me to set a username when I try to commit?

This means you haven't set either a local or global username yet. Git needs this information to stamp your commits. Set it with git config user.name "Your Name" for the current repository or add --global to set it for all repositories on your machine.