Check the Git config on your computer

Your Git username is stored in a configuration file on your machine. Open a terminal or command prompt and run this command:

git config user.name

The output will show the name you set when you first configured Git. If nothing appears, you have not yet set a username on this computer — which means Git will not know who you are when you make commits.

If you want to see all your Git settings at once, including email and other details, run git config --list. Your username will appear as user.name= followed by whatever name you chose.

Key Takeaways

  • Run git config user.name in your terminal to see the username Git has stored on your current computer.
  • If the command returns nothing, you have not yet set a username and should create one before making commits.
  • Your Git username is local to each computer — you may have different usernames on different machines.
  • Your Git username is separate from your GitHub, GitLab, or Bitbucket account name, though you can make them the same.

Understand the difference between Git username and account username

Git username and your account username on GitHub, GitLab, or Bitbucket are two separate things. Your Git username is what appears in the author field of every commit you make — it lives on your computer in a configuration file. Your account username is what you use to log in to a hosting service like GitHub.

When you push commits to GitHub, the hosting service matches your commits to your account based on the email address in the commit, not the username. So you can have a Git username of "Alice" on your computer and a GitHub account username of "alice.smith" — they do not have to match.

If you want to know your username on a specific hosting service, log in to that service and look at your account settings or profile page. That is separate from finding your Git username on your computer.

Set a username if you do not have one

If git config user.name returned nothing, you need to set a username before you start making commits. Run this command, replacing "Your Name" with whatever name you want to appear in your commit history:

git config user.name "Your Name"

This sets the username for your current user account on this computer only. If you want the same username on all your projects and all computers you use, add the --global flag:

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

You should also set your email address at the same time, since Git uses both together. Run git config --global user.email "your.email@example.com" with your actual email address.

Check your username in a specific repository

If you work on multiple projects and have set different usernames for different repositories, you can check which username applies to a specific folder. Navigate into that project folder in your terminal and run git config user.name without the --global flag.

Git checks for settings in this order: first the repository itself, then your user account on this computer, then the global settings. So if a repository has its own username set, that is what you will see. If not, Git falls back to your global or user-level setting.

This matters if you use the same computer for work and personal projects — you might want your work email and name in commits for your employer's repository, but your personal name in commits for your own projects.

Find your username on GitHub, GitLab, or Bitbucket

If you need to know your account username on a hosting service, log in to that service and look at your profile or account settings. On GitHub, click your profile picture in the top right corner and select "Your profile" — your username appears at the top of the page and in the URL. On GitLab, go to your profile picture and select "Edit profile" — your username is listed there. On Bitbucket, click your profile picture and select "Personal settings" — your username appears in the Account section.

Your account username is what you use in URLs when you clone repositories. For example, if your GitHub username is "alice-smith", a repository URL might look like https://github.com/alice-smith/my-project.git. This is different from your Git username, which is what appears inside the commits themselves.

Frequently Asked Questions

Can I have different Git usernames on the same computer?

Yes. You can set a global username that applies to all your projects, then override it for specific repositories by running git config user.name "Different Name" inside that repository folder without the --global flag. This is useful if you work on both personal and work projects on the same machine.

What happens if I do not set a Git username?

Git will refuse to make commits until you set a username and email address. You will see an error message telling you to configure user.name and user.email. You can set them at any point — even after you have already started working on a project.

Is my Git username the same as my GitHub username?

Not necessarily. Your Git username is what you set on your computer; your GitHub username is your account name on GitHub. They can be the same, but they do not have to be. GitHub matches your commits to your account using the email address in the commit, not the username.

How do I change my Git username?

Run git config user.name "New Name" to change it for the current repository, or git config --global user.name "New Name" to change it for all repositories on this computer. The change takes effect for new commits when ready — it does not change the author of commits you have already made.