Check your Git username from the command line
Your Git username is stored in your local Git configuration, and you can view it without opening any files or menus. Open your terminal and run this command:
git config user.name
This returns the username you set for commits on your current machine. If nothing appears, you have not yet configured a username — Git will need one before you can commit code. The username you see here is what appears as the author on every commit you make from this computer.
If you want to check the username set globally across all your projects on this machine, add the --global flag:
git config --global user.name
Key Takeaways
- Run git config user.name in terminal to see the username Git uses for commits on your current project.
- Add --global to the command to see the username that applies to all projects on your machine.
- Git does not store passwords in plain text in configuration files — it uses credential helpers or SSH keys instead.
- If you need to retrieve a stored password, check your system's credential manager rather than Git itself.
- You can change your username at any time by running git config user.name "Your New Name".
Understand the difference between project and global configuration
Git stores settings at two levels: project-level and global. When you run git config user.name without the --global flag, Git checks the current project first. If a username is set there, that is what you see. If not, Git falls back to your global setting.
This matters because you might use different usernames for different projects — one for work, one for personal code. The project-level setting always wins. To see all your configuration settings at once, run:
git config --list
This shows every setting Git knows about, including user.name, user.email, and many others. Scroll through the output to find what you need.
Why Git does not store passwords in configuration
Git intentionally does not keep passwords in its configuration files. Instead, it uses one of three methods to handle authentication: credential helpers, SSH keys, or personal access tokens. This design prevents passwords from sitting in plain text where they could be accidentally exposed.
If you set up Git to remember your credentials, they are stored by your operating system's credential manager — not by Git itself. On Windows, this is the Credential Manager. On macOS, it is the Keychain. On Linux, it is usually pass or another system tool you configured.
To see which credential helper Git is using, run:
git config credential.helper
If this returns nothing, you have not set up a credential helper, and Git will ask for your password each time you push or pull.
Retrieve stored credentials from your system
If you need to find a password Git is remembering, you must check your operating system's credential storage, not Git itself.
On Windows: Open Credential Manager (search for it in the Start menu), select "Windows Credentials", and look for entries labeled with your Git host — usually github.com, gitlab.com, or bitbucket.org. Click the entry and select "Show" to reveal the password.
On macOS: Open Keychain Access (in Applications > Utilities), search for your Git host name, double-click the entry, check "Show password", and enter your Mac password when prompted.
On Linux: If you are using pass, run pass show git/github.com (replace github.com with your host). If you are using a different credential helper, the retrieval method varies — check the documentation for the tool you installed.
Change your Git username in terminal
If you need to update your username, use the git config command with a new value. To change it for the current project only:
git config user.name "Your New Name"
To change it globally across all projects:
git config --global user.name "Your New Name"
The change takes effect when ready. Any commits you make after this point will show the new name as the author. Previous commits keep their original author name — changing the configuration does not rewrite history.
Verify your email address matches your Git account
Your Git username is only half the picture. Git also stores an email address, which is what most Git hosts (GitHub, GitLab, Bitbucket) actually use to link commits to your account. Check your email with:
git config user.email
This email must match one of the email addresses registered on your Git host account, or your commits will not appear under your profile. If the email is wrong or missing, update it the same way you update your username:
git config --global user.email "your.email@example.com"
After you change your email, new commits will use the new address. If you have already pushed commits with the wrong email, you can update them, but that requires rewriting history — a more advanced step.
Troubleshoot when Git returns nothing
If you run git config user.name and the terminal returns nothing, Git has no username set for that project or globally. This means your first commit will fail with an error asking you to set a username.
Set one when ready by running:
git config --global user.name "Your Name"
and
git config --global user.email "your.email@example.com"
After that, every commit will include your name and email. If you want a different username for a specific project, navigate into that project's folder and run the same commands without the --global flag — the project-level setting will override the global one.
Frequently Asked Questions
Can I see my password by running a git command?
No. Git does not store or display passwords through its configuration system. Passwords are kept by your operating system's credential manager. If you need to retrieve one, check your system's Credential Manager (Windows), Keychain (macOS), or credential helper (Linux).
What if I set up SSH keys instead of passwords?
SSH keys do not use passwords at all. Git uses the key pair stored on your machine to authenticate without asking for credentials. You can verify your SSH setup by running ssh -T git@github.com (replace github.com with your host). If it works, your SSH key is configured correctly.
Does changing my username in Git change my account on GitHub or GitLab?
No. Changing your Git configuration only affects commits made from your machine. Your account username on GitHub, GitLab, or other platforms stays the same. The Git username is just metadata attached to each commit you create.
Why does my username show differently on different computers?
Each computer has its own Git configuration. If you set up Git on one machine with one username and a different machine with another, they will not match. To keep them consistent, set your global username on every machine you use, or make sure your email address is the same — most Git hosts link commits by email, not by username.
Can I use my GitHub username as my Git username?
Yes, but it is not required. Your Git username is just a label on commits. Your GitHub account is identified by email address. You can set your Git username to anything — it does not have to match your GitHub username. What matters is that your Git email matches an email on your GitHub account.