Check your Git configuration file
Your Git username lives in a configuration file on your computer. The fastest way to find it is to open a terminal or command prompt and type a single command that reads this file back to you.
On Mac or Linux, open Terminal. On Windows, open Command Prompt or PowerShell. Then type this exactly:
git config user.name
Press Enter. Git will print your username on the next line. If nothing appears, you have not yet set a username on this computer — skip to the section "Set a username if you do not have one" below.
Check your global Git settings across all projects
The command above shows the username for your current folder only. If you want to see the username Git uses for every project on your computer, add the word --global to the command:
git config --global user.name
This reads your global settings file instead. Most people set a global username once and use it everywhere, so this is usually the one you want. If this command returns nothing, you have a local username set for individual projects but no global default.
You can also see all your global settings at once by typing git config --global --list. This shows your username, email, and other settings you have configured.
Key Takeaways
- Type git config user.name in your terminal to see the username for your current project.
- Type git config --global user.name to see the username Git uses for all projects on your computer.
- If neither command returns anything, you have not set a username yet and need to create one.
- Your username is separate from your GitHub account name — they can be different, and Git does not require GitHub at all.
- You can see all your Git settings at once with git config --global --list.
Find your username in the configuration file directly
If you prefer to look at the file itself instead of running a command, you can open it in a text editor. On Mac and Linux, the file is called .gitconfig and lives in your home folder. On Windows, it is also .gitconfig in your home folder (usually C:\Users\YourName).
The file is hidden by default on Mac and Linux because it starts with a dot. To see it, you need to show hidden files. On Mac, press Command+Shift+Period in Finder. On Linux, most file managers have a View menu with a "Show Hidden Files" option. On Windows, the file is usually visible in File Explorer.
Open the file with any text editor — Notepad, VS Code, or whatever you normally use. Look for a section that starts with [user]. Under it, you will see name = YourUsername. That is your Git username.
Understand the difference between Git username and GitHub username
Your Git username is what Git records when you make a commit on your computer. Your GitHub username is your account name on GitHub.com. They are not the same thing, and they do not have to match.
When you push your code to GitHub, GitHub shows the commit author as whatever name you set in Git — not your GitHub username. This is why you might see commits from people whose Git username does not match their GitHub profile name. If you want commits to show up under your GitHub account, you need to use the email address associated with your GitHub account in your Git configuration, not necessarily the same name.
To check what email Git is using, type git config user.email or git config --global user.email. Make sure this email matches one of the emails on your GitHub account settings.
Set a username if you do not have one
If the commands above returned nothing, you need to set a username before you can make commits. Type this command, replacing "Your Name" with whatever name you want Git to use:
git config --global user.name "Your Name"
You can use your real name, a nickname, or any string of text. Git does not validate it against anything — it just records whatever you type. If you want this username to explore only to one project instead of all projects, run the same command without --global while you are inside that project folder.
You should also set an email address at the same time, since Git requires both:
git config --global user.email "your.email@example.com"
After you run these commands, type git config --global user.name again to confirm the change took effect.
Check the username in a specific commit
If you want to see what username was used for a commit that already exists, you do not need to check your configuration — you can look at the commit itself. Type this command:
git log --oneline
This shows a list of recent commits with their messages. To see the full author name and email for each commit, type:
git log --format=fuller
This displays the author name, author email, commit date, and message for every commit in your project history. If you want to see details for just one commit, use git show CommitHash, replacing CommitHash with the first few characters of the commit you want to inspect.
Frequently Asked Questions
Can I have different usernames for different projects?
Yes. Set a global username with --global, then go into a specific project folder and run git config user.name "Different Name" without --global. Git will use the local username for that project and the global username for everything else.
What if I set the wrong username and want to change it?
Run git config --global user.name "Correct Name" to update it. This only affects new commits going forward — old commits keep the name they were made with. If you need to change the author on existing commits, that requires rewriting history, which is more complex.
Does my Git username have to match my GitHub username?
No. Your Git username is just a label Git puts on commits. GitHub shows commits under your account based on the email address in the commit, not the name. You can have any Git username and still get credit on GitHub as long as the email matches your GitHub account.
Where is the .gitconfig file on Windows?
It is in your home folder, usually C:\Users\YourName\.gitconfig. You can also type git config --global --list in Command Prompt to see the settings without opening the file.
What if git config returns nothing but I know I set a username?
You may have set a local username for that project only. Try git config --global user.name instead. If that also returns nothing, run git config --global user.name "Your Name" to set one.