The fastest way to check your GitHub username

Open your terminal and run git config user.name. This shows the name you set up when you first configured Git on your computer — which may or may not match your actual GitHub username.

If you want to see the email address linked to your Git configuration, run git config user.email. Both of these settings are stored locally on your machine, so they tell you what Git is using for commits you make, not necessarily what your GitHub account is called.

To find your actual GitHub username (the one you use to log in and the one that appears in your GitHub profile URL), you need to check your GitHub account directly or use the GitHub API from the terminal.

Key Takeaways

  • git config user.name shows the name Git uses for commits, which is often different from your GitHub username.
  • Your GitHub username is the handle in your profile URL — for example, github.com/your-username — and you can see it by logging into GitHub in a browser.
  • You can retrieve your GitHub username from the terminal using curl and the GitHub API if you have a personal access token set up.
  • The email address in your Git configuration may not match the email on your GitHub account, so checking both is useful when troubleshooting push errors.

Checking your Git configuration versus your GitHub account

Git and GitHub are separate tools. Git is the version control system that runs on your computer; GitHub is the website where you store and share repositories. When you first set up Git, you told it what name and email to use when you make commits. That name is not your GitHub username — it is just a label Git attaches to your work.

For example, you might have configured Git with the name "Jane Smith" and the email "jane@example.com", but your GitHub username could be "janesmith42" or anything else. When you push commits to GitHub, Git sends both the commit message and the name you configured — but GitHub matches the commit to your account based on the email address, not the name.

This is why you might see commits attributed to "Jane Smith" on GitHub even though your username is different. The name in your Git configuration is what appears in the commit history; your GitHub username is what appears in your profile and in your repository URL.

Using the GitHub API to retrieve your username from the terminal

If you have a personal access token set up on GitHub, you can use curl to fetch your account information directly from the GitHub API. Run this command:

curl -H "Authorization: token YOUR_TOKEN_HERE" https://api.github.com/user

Replace YOUR_TOKEN_HERE with your actual personal access token. The response will be a block of JSON data that includes your username under the "login" field. This is the most reliable way to check your GitHub username from the terminal because it pulls the information directly from your GitHub account.

If you do not have a personal access token yet, you can create one on GitHub by going to Settings > Developer settings > Personal access tokens > Tokens (classic). You only need the read:user scope to retrieve your username. Store the token somewhere safe — you will not be able to see it again after you close the page.

Why your Git name and GitHub username matter for pushing code

When you push commits to a GitHub repository, GitHub uses the email address in your Git configuration to match the commit to your account. If the email does not match any email on your GitHub account, the commit will be attributed to an unrecognized user — it will still appear in the repository, but it will not show as coming from you.

You can add multiple email addresses to your GitHub account under Settings > Emails. GitHub will recognize commits from any of those addresses. If you are working on multiple machines or with multiple Git configurations, make sure the email you set in Git matches one of the emails on your GitHub account.

The name you set in Git configuration does not have to match your GitHub username or your real name — it is purely for display in the commit history. Many people use their real name, but you can set it to anything. To change it, run git config --global user.name "Your Name" to update it across all repositories on your machine, or git config user.name "Your Name" inside a specific repository to change it only there.

Checking your username in different Git hosting scenarios

If you use GitHub through an organization account or have multiple GitHub accounts on the same machine, the process is slightly different. Your personal Git configuration only knows about the name and email you set — it does not know which GitHub account you are pushing to.

When you push to a repository, Git uses the remote URL to determine where the code goes. If the URL contains your username (for example, git@github.com:your-username/repo-name.git), that username is part of the URL, not part of your Git configuration. You can see which remote URL a repository is using by running git remote -v in that repository.

If you have set up SSH keys for GitHub, the key you use determines which account the push is attributed to. If you have multiple SSH keys on your machine, make sure the one being used matches the GitHub account you want to push to. You can check which key Git is using by running ssh -v git@github.com — the output will show which key was loaded.

Troubleshooting when your username does not match your account

If you see commits attributed to the wrong person or to an unrecognized user, the problem is usually a mismatch between your Git email and your GitHub account emails. Run git config user.email to see what email Git is using, then check your GitHub Settings > Emails to see what emails are registered on your account.

If the email in Git does not appear on your GitHub account, add it under Settings > Emails, or change your Git configuration to use an email that is already on your account. After you change your Git configuration, new commits will be attributed correctly — old commits will not change because they are already recorded with the old email.

If you are pushing to a repository and getting a "permission denied" error, the problem may be that your SSH key or HTTPS credentials are set up for a different GitHub account. Check which account your SSH key is registered to, or make sure you are using the correct username and personal access token (not your password) if you are using HTTPS.

Frequently Asked Questions

Is my Git user.name the same as my GitHub username?

No. Your Git user.name is just a label for commits on your local machine. Your GitHub username is the handle you use to log in and the one in your profile URL. They are often different, and that is normal. GitHub matches commits to your account using your email address, not your name.

How do I change my GitHub username from the terminal?

You cannot change your GitHub username from the terminal — you have to do it on GitHub.com. Go to Settings > Account, find the "Change username" option, and follow the prompts. GitHub will update your profile URL, but old links to your repositories may stop working, so update them where you can.

What if git config user.name shows nothing?

Git has not been configured yet on your machine. Run git config --global user.name "Your Name" and git config --global user.email "your-email@example.com" to set it up. Use an email that matches one on your GitHub account so commits are attributed correctly.

Can I have different Git usernames for different projects?

Yes. Run git config user.name "Name" inside a specific repository (without the --global flag) to set a different name just for that project. This overrides your global setting for that repository only. This is useful if you work on both personal and work projects with different identities.

Why do my commits show as "unverified" on GitHub?

Commits are unverified when they are not signed with a GPG key. This is different from attribution — your name and email are correct, but GitHub cannot confirm you actually made the commit. You can sign commits with a GPG key if you want the "Verified" badge, but it is optional.