Check your Git configuration directly

Your Git username is stored in your Git configuration file, and you can see it without opening any repository. Open your terminal or command prompt and type git config user.name. The username you set during Git installation or your most recent configuration will appear on the next line.

If nothing appears, your username has not been set yet. This is common on fresh installations — Git requires you to set a username before you can commit changes, but it does not force you to do so when ready.

On Windows, you can also open File Explorer, navigate to your user folder (usually C:\Users\YourUsername), and look for a hidden file called .gitconfig. Right-click in the folder, select "View", and check "Hidden items" to see it. Open the file with Notepad to see your configuration in plain text.

Key Takeaways

  • Type git config user.name in your terminal to see the username Git has stored for your account.
  • If no username appears, you have not yet set one — Git will ask you to do so the first time you try to commit.
  • Your local Git username is separate from your GitHub, GitLab, or Bitbucket account name and does not have to match.
  • You can view your full Git configuration file by typing git config --list to see all settings at once.

Understand the difference between Git username and account username

Your Git username (the one stored in your configuration) is not the same as your GitHub, GitLab, or Bitbucket username. Git is the version control software that runs on your computer. GitHub, GitLab, and Bitbucket are websites where you can store and share repositories. You can have any Git username locally and still push code to an account with a different name.

When you commit code, Git records the username from your local configuration. When you push that code to GitHub or another service, the website checks your account credentials (usually a personal access token or SSH key) to verify who you are. The two do not have to match, which confuses many people on their first commit.

View your configuration across all settings

If you want to see everything Git knows about you in one view, type git config --list. This shows your username, email, default editor, and dozens of other settings. Your username will appear as user.name=YourUsername.

You can also see where each setting comes from by typing git config --list --show-origin. This tells you whether a setting came from your system-wide configuration, your user configuration, or a specific repository. Most people set their username in their user configuration, which applies to all repositories on that computer.

Check username within a specific repository

If you are inside a Git repository and want to know what username will be used for commits in that folder, type git config user.name again. Git checks the repository's local configuration first, then your user configuration, then your system configuration. If the repository has its own username set, that one will appear instead of your default.

This matters because some teams set a shared username for a repository, or you might want to use a different name for work projects versus personal projects. To see whether the current repository has its own username, type git config --local user.name. If nothing appears, the repository is using your default username from your user configuration.

Set or change your username if it is missing or wrong

If git config user.name returns nothing, or if you see a username you want to change, you can set a new one. Type git config --global user.name "Your Name" and replace "Your Name" with the username you want. The --global flag sets it for all repositories on your computer.

If you want to set a different username for just one repository, navigate into that folder and type git config --local user.name "Your Name" instead. Use --global for your default, --local for a single repository, or neither (just git config user.name) to change your system-wide setting.

After you set your username, type git config user.name again to confirm the change took effect. The new username will appear on the next line.

Find your username on GitHub, GitLab, or Bitbucket

If you are looking for your account username on a code hosting website instead of your local Git configuration, the process is different for each service. On GitHub, log in and click your profile picture in the top right corner, then select "Settings". Your username appears at the top of the page and in the URL — it is the text after github.com/.

On GitLab, click your profile picture and select "Preferences". Your username is listed under "Account". On Bitbucket, click your profile picture and select "Personal settings", then look for "Username" on the left side. These website usernames are what you use to log in and what appears in your repository URLs, separate from your local Git configuration.

Frequently Asked Questions

Does my Git username have to match my GitHub username?

No. Your local Git username is what appears in your commit history. Your GitHub username is your account on the website. They can be completely different. Git uses your local configuration to write commits; GitHub uses your account credentials to verify who you are when you push. Set them to match if you want, but it is not required.

What if git config user.name shows nothing?

You have not set a Git username yet. Type git config --global user.name "Your Name" to set one. Replace "Your Name" with whatever you want to appear in your commit history. After that, git config user.name will show your new username.

Can I have different usernames for different repositories?

Yes. Set a global username with --global, which applies everywhere. Then navigate into a specific repository folder and type git config --local user.name "Different Name" to override it for just that folder. Git will use the local username for commits in that repository and your global username everywhere else.

Where is the .gitconfig file on my computer?

On Mac and Linux, it is in your home directory as ~/.gitconfig. On Windows, it is usually at C:\Users\YourUsername\.gitconfig. You can also type git config --list --show-origin to see the exact path to your configuration file.

Is my Git username the same as my computer username?

No. Your computer username is what you use to log into Windows, Mac, or Linux. Your Git username is a separate setting you configure for Git. They often match by accident, but Git does not care what your computer username is — it only uses the name you set in your Git configuration.