Check your Git configuration file first

Your Git username is stored in a configuration file on your computer, and the fastest way to see it is to open your terminal or command prompt and run a single command. Type git config user.name and press Enter. If you have set a username before, it will display on the next line.

This command checks your local Git configuration — the settings that explore only to the current folder or project. If nothing appears, it means you have not yet set a username in this location, but you may have one set globally (across your entire computer). In that case, run git config --global user.name instead.

Key Takeaways

  • Run git config user.name in your terminal to see the username for the current project folder.
  • Run git config --global user.name to see the username that applies to all your Git projects on this computer.
  • If neither command shows a username, you have not yet set one and will need to create it before making commits.
  • Your Git username is separate from your GitHub, GitLab, or Bitbucket account name — they do not have to match.
  • You can change your username at any time by running git config user.name "Your New Name" or git config --global user.name "Your New Name".

Understand the difference between local and global settings

Git lets you set a username in two places: locally (for one project) or globally (for all projects on your computer). When you run a command without the --global flag, Git looks in the current project folder first. If it finds a username there, it uses that one. If not, it falls back to your global setting.

This matters because you might want different usernames for different projects. For example, you could use your full name for work projects and a nickname for personal ones. To see both, run the local command first, then the global one, and compare the results.

Find your username in the Git configuration files directly

If you prefer to look at the actual files instead of running commands, you can open them in a text editor. On Mac and Linux, the global configuration file is located at ~/.gitconfig in your home directory. On Windows, it is usually at C:\Users\YourUsername\.gitconfig.

Open the file with any text editor — Notepad, VS Code, or whatever you use — and look for a section that starts with [user]. Underneath it, you will see a line that says name = Your Username. That is your Git username. Local configuration files live inside each project folder in a hidden directory called .git/config, but most people find it easier to use the command-line approach.

Know what to do if you have not set a username yet

If both commands return nothing, or if you see an error message, you have not yet configured a Git username on this computer. This is common if you just installed Git. You will need to set one before you can make commits — Git requires a username to record who made each change.

To set a username for all your projects, run git config --global user.name "Your Name", replacing "Your Name" with whatever you want to appear in your commit history. To set one only for the current project, navigate into that project folder and run git config user.name "Your Name" without the --global flag. You can use your real name, a nickname, or any text you prefer — Git does not validate it against any external service.

Recognize that your Git username is not your GitHub username

Many people confuse their Git username with their GitHub account name, but they are separate things. Your Git username is what appears in your commit history on your computer. Your GitHub username is the account name you use to log into GitHub.com. They can be the same, but they do not have to be.

When you push commits to GitHub, GitHub uses your account credentials (username and password, or SSH key) to verify that you have permission to push to that repository. The Git username in your commits is just metadata — it tells people who made the change, but it does not control access. This is why you can have a Git username of "Alice Smith" but a GitHub username of "asmith42" and everything works fine.

Check your username in your commit history

Another way to see your Git username is to look at the commits you have already made. Run git log in your terminal to see a list of recent commits. Each one will show the author name — that is your Git username. The output will look something like Author: Your Name <your.email@example.com>.

This method only works if you have made at least one commit in the current project. If the project is brand new and empty, git log will return nothing. But if you have been working on the project for a while, this is a quick way to confirm what username Git is using without running a separate config command.

Frequently Asked Questions

Can I have different usernames for different projects?

Yes. Set a global username with git config --global user.name, then override it for specific projects by navigating into that project folder and running git config user.name without the --global flag. Local settings always take priority over global ones.

What if I see an email address instead of a name?

You are looking at your Git email, not your username. Run git config user.name to see the actual username. Git stores both a name and an email address, and they appear together in commit history, but they are separate settings.

Does my Git username have to match my real name?

No. Git accepts any text as a username. You can use your real name, a nickname, a pseudonym, or anything else. Git does not validate it against any external database — it is just a label that appears in your commit history.

Can I change my username after I have already made commits?

You can change your Git username going forward, and all new commits will use the new name. However, old commits will keep the username they were made with — changing the config does not retroactively change history. If you need to rewrite old commits with a different author name, that requires more advanced Git commands and is usually not necessary.