The command to see your global username
Open your terminal or command prompt and type this:
git config --global user.name
Press Enter. If you have set a global username, it will print that name on the next line. If nothing prints, you have not set a global username yet — Git will ask you to provide one the first time you commit.
This command reads from your Git configuration file, which Git stores on your computer. It does not connect to any server or check what name you use on GitHub or another platform. It only shows what you told Git to use locally.
Key Takeaways
- Run git config --global user.name in your terminal to see the username Git will use for all your commits on that computer.
- If the command returns nothing, you have not yet set a global username and will need to create one before your first commit.
- Your global Git username is separate from your GitHub username, GitLab username, or any other platform — it is only what Git uses locally.
- You can also check your email with git config --global user.email using the same method.
Where Git stores your username
Git keeps your global configuration in a hidden file on your computer. On Mac and Linux, it is in your home directory as .gitconfig. On Windows, it is usually in C:\Users\[YourUsername]\.gitconfig.
You do not need to open this file directly. The git config command reads it for you. But if you want to see the whole file and all your settings at once, you can type git config --global --list and it will print every global setting Git knows about.
What to do if you have not set a username yet
If git config --global user.name returns nothing, you need to set one before you make your first commit. Use this command:
git config --global user.name "Your Name"
Replace "Your Name" with whatever you want to appear in your commit history. This can be your real name, a nickname, or any text. Git does not verify it against any database — it just stores what you type.
You should also set your email at the same time:
git config --global user.email "your.email@example.com"
After you run both commands, you can verify they worked by running git config --global user.name and git config --global user.email again.
The difference between global and local usernames
The --global flag means the username applies to every Git project on your computer. If you want a different username for just one project, you can set a local username instead. Navigate into that project's folder and run the same command without --global:
git config user.name "Different Name"
When you commit in that folder, Git will use the local username. In all other folders, it will use the global one. This is useful if you work on personal projects under one name and work projects under another.
Checking your username on different computers
Your Git configuration lives on each computer separately. If you use Git on your laptop, your desktop, and a work machine, each one has its own .gitconfig file. You may have set a username on one computer but not the others.
To check what username you have on any computer, open a terminal on that machine and run git config --global user.name. If you want the same username everywhere, you will need to set it on each computer individually.
Why Git asks for a username when you commit
Every commit you make records who created it. Git uses your global username and email to fill in that information. If you have not set them, Git will refuse to let you commit and will tell you to run the git config commands first.
This is not about security or authentication — Git is not checking your identity against a server. It is just making sure every commit has a name attached so you and your team can see who made each change.
Frequently Asked Questions
Is my Git username the same as my GitHub username?
No. Your Git username is what you set locally on your computer with git config. Your GitHub username is your account name on GitHub.com. They can be the same, but they do not have to be. Git does not know or care what your GitHub username is.
Can I change my username after I have already committed?
You can change your global username with git config --global user.name "New Name", and all future commits will use the new name. Old commits will keep the name you used when you made them. If you need to change the author on past commits, that requires more advanced Git commands and is usually not necessary.
What if I see different usernames in different projects?
You probably set a local username in some projects. Run git config user.name (without --global) inside each project folder to see if it has its own username. If it does, that one overrides your global username for that project only.
Does my Git username have to be my real name?
No. Git stores whatever text you give it. You can use a nickname, a handle, or any string. The only person who sees it is whoever reads your commit history, so choose something you are comfortable with in a work or public context if your code will be shared.