Check your Git configuration file first
Your Git username is stored in a configuration file on your computer, and the fastest way to find it is to open that file directly. Git saves your username in one of three places depending on how you set it up: your user account settings (global), your current project folder (local), or your system-wide settings. Most people use the global setting, which applies to every project you work on.
On Windows, this file lives at C:\Users\[YourUsername]\.gitconfig. On Mac and Linux, it's in your home directory at ~/.gitconfig. You can open it with any text editor — Notepad on Windows, TextEdit on Mac, or nano in the terminal on Linux. Look for a line that says [user] followed by name = YourUsername. That name value is your Git username.
Key Takeaways
- Your Git username is stored in a plain text file called .gitconfig in your home directory, which you can open with any text editor.
- Running git config user.name in the terminal tells you your global username when ready without opening any files.
- If you have set different usernames for different projects, the local project setting overrides your global setting.
- Your Git username is not the same as your GitHub username, GitLab username, or email address — it is a separate setting you chose when you first configured Git.
Use the command line to see your username when ready
If you are comfortable opening a terminal or command prompt, this is the quickest method. Open your terminal (Terminal on Mac, Command Prompt or PowerShell on Windows, or any terminal on Linux) and type this command:
git config user.name
Press Enter. Git will print your username on the next line. If nothing appears, your global username is not set yet. If you want to see your local username for a specific project, navigate into that project folder first (using cd on any system) and run the same command — Git checks the local setting first, then falls back to the global one.
Understand the difference between global and local usernames
When you first install Git, you set a global username that applies to every project. But you can also set a different username just for one specific project folder. This is useful if you work on personal projects under one name and professional projects under another.
To check if your current project has its own local username, open a terminal in that project folder and run git config --local user.name. If a username appears, that project is using a local setting. If nothing appears, the project is using your global username. The local setting always takes priority — Git uses the local username for commits in that folder, even if your global username is different.
Find your username in a recent commit
If you have already made commits to a Git project, your username is recorded in those commits. Open a terminal in the project folder and run:
git log --oneline -1
This shows your most recent commit. The output will look something like a1b2c3d (HEAD -> main) Your commit message. To see the full commit details including the username, run:
git log -1
Look for the line that starts with Author:. The name before the email address is your Git username. This method only works if you have made at least one commit in the project.
Set or change your Git username if it is missing
If you cannot find your username using any of these methods, it was never set. Git requires a username before you can make commits, so you will need to create one now. In a terminal, run:
git config --global user.name "Your Name"
Replace "Your Name" with whatever username you want to use. This can be your real name, a nickname, or any text you choose — Git does not validate it against any external service. After you run this command, verify it worked by running git config user.name again. If you want to set a different username just for one project, navigate into that project folder and run the same command with --local instead of --global.
Know what your Git username is not
Your Git username is separate from several other usernames you might have. It is not your GitHub username, even if you push your code to GitHub. It is not your GitLab username, Bitbucket username, or any other service. It is also not your email address, though you can set it to look like one if you want.
Your Git username is purely local — it only matters on your own computer and in the commit history of projects you work on. When you push code to GitHub or another service, that service uses your account credentials (username and password, or SSH key) to authenticate you, not your Git username. Two people can have the same Git username on their own computers and push to the same GitHub repository without any conflict, because GitHub only cares about who authenticated the push, not what name is written in the commit.
Frequently Asked Questions
Is my Git username the same as my GitHub username?
No. Your Git username is a local setting on your computer. Your GitHub username is your account name on GitHub's website. They can be different. When you push code to GitHub, GitHub uses your account credentials to verify who you are, not your Git username. However, many people set them to match for simplicity.
What if git config user.name returns nothing?
Your global username has not been set. Run git config --global user.name "Your Name" to create one. If you are in a project folder and want to check only the local setting, run git config --local user.name instead. If that returns nothing too, the project is using your global username.
Can I have different usernames for different projects?
Yes. Set a global username with --global, then navigate into any project folder and run git config --local user.name "Different Name" to override it just for that project. Git always uses the local setting if one exists, otherwise it falls back to global.
Where is the .gitconfig file on Windows?
It is in your user home directory at C:\Users\[YourUsername]\.gitconfig. The dot at the start makes it a hidden file in Windows, so you may need to enable "Show hidden files" in File Explorer to see it. You can also open it directly by typing the full path into Notepad.
Does my Git username have to be my real name?
No. Git does not validate your username against any external service. You can set it to any text you want — a nickname, a pseudonym, your email address, or anything else. It is purely for identification in your commit history.