Change your Git username with a single command
Your Git username is the name that appears on every commit you make. You change it by running git config with the user.name setting. The command takes just one line, and the change happens when ready — no restart needed.
Git stores usernames in two places: locally (for one folder) or globally (for all folders on your computer). Most people want the global change, which is what this guide covers. If you need to use different names for different projects, you can override the global setting in individual folders.
The username you set here is purely for your own records and your team's visibility. It does not authenticate you to GitHub, GitLab, or any other service. Those platforms use SSH keys or personal tokens instead.
Key Takeaways
- Run git config --global user.name "Your Name" to change your username everywhere on your computer.
- The change takes effect when ready and applies to all new commits you make from that point forward.
- Old commits keep their original username — changing the setting does not rewrite history.
- You can check what username is currently set by running git config user.name without the new name.
- If you need a different username for one specific project, run the same command without --global inside that folder.
Set your username globally across all projects
Open your terminal or command prompt and type this command, replacing "Your Name" with the name you want to appear on commits:
git config --global user.name "Your Name"
Press Enter. Git will not print a confirmation message — that is normal. The setting is now saved. Every commit you make from now on will show this name as the author.
If your name contains special characters or spaces, keep the quotes around it. For example: git config --global user.name "María García" or git config --global user.name "Jean-Pierre Dupont".
Verify the username was changed
To confirm the change took effect, run this command:
git config user.name
Git will print back the name you just set. If nothing prints, the setting was not saved — try the first command again and check for typos.
You can also see your full Git configuration by running git config --global --list, which shows every global setting at once. Look for the line that starts with user.name=.
Change the username for just one project
If you work on projects where you need different names — for example, a work project under your company name and a personal project under your own name — you can override the global setting in a single folder.
Navigate into the project folder and run the same command without the --global flag:
git config user.name "Different Name"
This creates a local setting that applies only to that folder and overrides your global username. When you commit in that folder, Git uses the local name. When you commit in any other folder, Git uses the global name.
To check what username is active in your current folder, run git config user.name again. It will show the local setting if one exists, or fall back to the global setting if not.
Understand what the username does and does not do
The username you set in Git is metadata — it is the name that appears in the commit log and in tools like GitHub or GitLab when people view your history. It is purely informational and does not control who can push code or access repositories.
Authentication to GitHub, GitLab, Bitbucket, or other platforms happens separately through SSH keys, personal tokens, or username-and-password login. Changing your Git username does not change those credentials and does not affect your ability to push or pull code.
The username is also not your email address, though Git also stores an email separately. You can set that with git config --global user.email "your.email@example.com" using the same approach.
What happens to old commits after you change your username
Changing your Git username does not rewrite old commits. Any commit you made before the change will still show the old username when you view the history. Only new commits made after the change will show the new name.
If you need to change the author name on old commits, that requires rewriting history with commands like git rebase or git filter-branch. This is advanced and can cause problems if other people have already pulled those commits. For most situations, leaving old commits as they are is the right choice.
Troubleshooting common problems
If you run git config user.name and see nothing, or see a different name than you expected, check whether a local setting is overriding your global one. Navigate to the project folder and run git config --local user.name to see if a local setting exists. If it does, you can remove it with git config --local --unset user.name, which will make Git fall back to the global setting.
If you typed the command but it did not work, check for typos in the command itself. The flag is --global (two hyphens), not -global (one hyphen). Also make sure you are using straight quotes, not curly quotes — some text editors and word processors convert quotes automatically, which breaks the command.
On Windows, if you see an error about the command not being recognized, make sure Git is installed and added to your system PATH. You can test this by running git --version. If that works, the username command should work too.
Frequently Asked Questions
Does changing my Git username affect my GitHub account?
No. Your Git username is local to your computer and is separate from your GitHub username. Changing one does not change the other. GitHub uses your account credentials (SSH key or personal token) to identify you, not the name in your Git config.
Can I use a different username for different projects?
Yes. Run git config user.name "Name" without --global inside the project folder. That creates a local setting that overrides your global username only in that folder. All other folders will still use the global name.
Will changing my username affect commits I already made?
No. Old commits keep the username that was set when you made them. Only new commits will show the new username. Rewriting old commits requires advanced commands and is not recommended unless you have a specific reason.
What if I set the wrong username by mistake?
Just run the command again with the correct name. Git will overwrite the old setting when ready. If you want to go back to having no username set, run git config --global --unset user.name.
Is the Git username the same as my email address?
No. Git stores username and email separately. You set the username with user.name and the email with user.email. Both appear on commits, but they are different settings and can contain different information.