Check your GitLab username with a single git command

The fastest way to see your GitLab username in the terminal is to run git config user.name. This command displays the name you have set in your local Git configuration — the one Git uses when you commit code. If you have never set a local username, it will show nothing, and you will need to check your global configuration instead.

If you want to see both your local and global usernames at once, run git config --list | grep user. This shows every user-related setting Git knows about, including your email address. The output will show user.name and user.email for whichever scope (local or global) has them set.

Key Takeaways

  • git config user.name shows the username Git will use for commits in your current project folder.
  • git config --global user.name shows the username Git uses for all projects on your machine unless overridden locally.
  • git config --list | grep user displays all user settings at once, making it straightforward to spot which scope has which name.
  • Your local Git username and your actual GitLab account username are separate — Git's setting is just what appears in commit history.

Understand the difference between local and global configuration

Git stores usernames in two places: local (for a single project) and global (for your entire machine). When you commit code, Git looks for a local username first. If it does not find one, it uses the global setting. If neither exists, Git will refuse to commit until you set one.

To check your global username, run git config --global user.name. To check the local username for just the current project, run git config user.name without the --global flag. If you are in a folder that is not a Git repository, the local command will return nothing.

Most people set a global username once and leave it alone. You might set a local username only if you work on a project that needs a different name — for example, using your company name for work repositories and your personal name for open-source ones.

View your configuration file directly

You can also read the configuration files themselves instead of using Git commands. Your global configuration lives in ~/.gitconfig (or ~/.config/git/config on some Linux systems). Your local configuration for a project lives in .git/config inside that project's folder.

To view your global config, run cat ~/.gitconfig. To view a project's local config, navigate into the project folder and run cat .git/config. Both files are plain text, and you will see the username under the [user] section. This method is useful if you want to see all your Git settings at once, not just the username.

Remember that Git username is not the same as GitLab username

Your Git username — the one you set with git config user.name — is just a label that appears in your commit history. It does not have to match your actual GitLab account username. You could set your Git username to "Alice Smith" while your GitLab account is asmith42, and Git will not complain.

This matters because when you push code to GitLab, the platform identifies you by your SSH key or personal access token, not by the name in your commits. The Git username only affects what name shows up in the commit log. If you need to find your actual GitLab account username, you have to log into GitLab itself — the terminal cannot tell you that.

Set or change your Git username if it is missing or wrong

If git config user.name returns nothing, or if it shows a name you do not want to use, you can set it. To set a global username that applies to all your projects, run git config --global user.name "Your Name". Replace "Your Name" with whatever you want to appear in your commits.

To set a local username for just the current project, navigate into that project's folder and run git config user.name "Your Name" without the --global flag. After you set it, run git config user.name again to confirm the change took effect.

Verify your username is set before making commits

Before you commit code for the first time on a new machine or in a new project, always check that your username is set. Run git config user.name and make sure it returns something. If it does not, Git will reject your commit with an error message asking you to set user.name and user.email.

It is faster to set these once at the start than to hit that error later. If you work on multiple projects with different usernames, check the local config for each one. A quick git config user.name in each folder takes seconds and saves you from committing under the wrong name.

Frequently Asked Questions

What if git config user.name returns nothing?

You have not set a username yet, either locally or globally. Run git config --global user.name "Your Name" to set one. After that, git config user.name will show it in any project folder.

Can I have different usernames for different projects?

Yes. Set a global username with git config --global user.name, then override it in specific projects by running git config user.name "Different Name" inside that project folder. Git will use the local name for commits in that folder only.

Does my Git username have to match my GitLab account username?

No. Your Git username is just a label in commit history. GitLab identifies you by your SSH key or token, not by the name in your commits. You can set your Git username to anything and still push to GitLab without problems.

How do I see my email address too?

Run git config user.email to see your local email, or git config --global user.email for your global email. You can also run git config --list | grep user to see both name and email at once.