Your Git username is stored in your local Git configuration file, and you can view it with a single command in your terminal or command prompt.

Git stores your username in a configuration file on your computer. The fastest way to see it is to open your terminal (on Mac or Linux) or command prompt (on Windows) and run a command that pulls the setting directly from that file. You do not need to log into anything or navigate through menus — Git will show you what it has on record in seconds.

The username Git uses is separate from your GitHub username, your GitLab username, or any other service. It is the name you set up when you first configured Git on this particular computer. If you have never set one, or if you set it on a different device, you may see nothing — and that is the point of checking.

Key Takeaways

  • Run git config user.name in your terminal to see the username Git has stored on your current device.
  • If the command returns nothing, you have not yet set a Git username on this computer, and you will need to create one before making commits.
  • Your Git username is local to each device — setting it on your laptop does not change it on your desktop or work computer.
  • You can view your global username (the one Git uses for all projects) or your project-specific username (the one Git uses only in a single folder).

Check your global Git username

Your global username is the one Git uses for every project on your computer unless you override it. To see it, open your terminal or command prompt and type the following command exactly:

git config --global user.name

Press Enter. If you have set a global username, Git will print it on the next line. If nothing appears, you have not yet set one on this device. The command will not produce an error — it will straightforward return nothing, which tells you the setting does not exist.

This command works the same way on Windows, Mac, and Linux. You do not need administrator rights or any special permissions.

Check your project-specific Git username

Some people set a different username for a single project or folder. This overrides the global username only within that folder. To check if a project has its own username, navigate into the project folder first, then run:

git config user.name

Notice there is no --global flag this time. If the project has its own username, Git will print it. If it does not, Git will print nothing — which means the project is using your global username instead.

This is useful if you work on personal projects in one folder and work projects in another, and you want each to show a different name in the commit history.

What to do if no username appears

If both commands return nothing, Git does not have a username set on your computer yet. You will need to create one before you can make commits. The command to set a global username is:

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

Replace "Your Name Here" with whatever name you want Git to use. This can be your real name, a nickname, or any text you choose. Once you run this command, Git will store it and use it for all future commits on this device.

If you want to set a username for only one project instead, navigate into that project folder and run the same command without the --global flag:

git config user.name "Your Name Here"

View all your Git configuration settings at once

If you want to see your username along with your email address and other Git settings, run:

git config --global --list

This will print every global setting Git has stored, including user.name and user.email. Each setting appears on its own line. If you want to see only the project-specific settings for the folder you are in, run the same command without --global:

git config --list

This is helpful if you want to double-check that both your username and email are set before you start working on a new project.

Where Git stores your username

Your global Git username is stored in a hidden file called .gitconfig in your home directory. On Mac and Linux, this is ~/.gitconfig. On Windows, it is usually C:\Users\YourUsername\.gitconfig. You can open this file in any text editor and see the raw configuration, though using the git config command is simpler and safer.

Project-specific usernames are stored in a hidden folder called .git inside your project. This folder is created automatically when you initialize a Git repository or clone one from a service like GitHub. You should not edit these files by hand — always use the git config command instead.

Frequently Asked Questions

Is my Git username the same as my GitHub username?

No. Your Git username is what you set on your computer and what appears in your commit history. Your GitHub username is your account name on GitHub.com. They can be different. When you push commits to GitHub, GitHub sees both your Git username (in the commit) and your GitHub account (from your login credentials), but they do not have to match.

Can I have a different Git username on each of my computers?

Yes. Git configuration is stored locally on each device. You can set one username on your laptop, a different one on your desktop, and a third one on your work computer. Each device has its own .gitconfig file, so they do not affect each other.

What if I see a username I did not set?

If you see a username you do not recognize, someone else may have configured Git on this device before you. You can change it by running git config --global user.name "Your Name" with your preferred name. This will overwrite the old setting.

Do I need to set my Git username before cloning a repository?

You can clone a repository without setting a username. However, you will need a username set before you make your first commit. If you try to commit without one, Git will refuse and ask you to set it first.

Why does Git ask for a username and email separately?

Git stores both your name and email in every commit you make. The email is used to identify you across different systems and services. You set both with separate commands: git config --global user.name and git config --global user.email. Both are required before you can commit.