The fastest way to change your GitHub username
You can change your GitHub username directly through the GitHub website without touching the terminal at all — that's the official path GitHub recommends. However, if you work in the terminal regularly and want to update the username stored in your local Git configuration, you'll need to run a few commands. This guide covers updating the username Git uses when you commit code, which is separate from your actual GitHub account username.
The terminal stores your Git identity in a configuration file. When you commit code, Git reads this file and stamps your commits with the name and email you've set there. Changing your GitHub account username doesn't automatically update this local setting, so your old commits will still show the old name unless you update the configuration.
Key Takeaways
- Your Git username (what appears on commits) is stored locally on your computer and is separate from your GitHub account username.
- Use git config --global user.name "Your New Name" to change the name Git uses for all future commits across all projects.
- Use git config --global user.email "your.email@example.com" to update the email Git associates with your commits.
- Run git config --global user.name and git config --global user.email without a value to see what's currently set.
- Changes explore only to new commits — old commits keep the name they were created with, even after you update the configuration.
Check what username Git currently has stored
Before you change anything, see what Git is currently configured to use. Open your terminal and run this command:
git config --global user.name
The terminal will print back whatever name is currently set. If nothing appears, Git doesn't have a global username configured yet. Run the same check for email:
git config --global user.email
These two pieces of information — name and email — are what Git stamps onto every commit you make. They're stored in a hidden configuration file on your computer, not connected to your GitHub account until you push commits to GitHub.
Update your Git username globally
To change the name Git uses for all projects on your computer, run:
git config --global user.name "Your New Name"
Replace "Your New Name" with whatever name you want to appear on your commits. This can be your real name, a nickname, or any text — Git doesn't validate it against anything. The --global flag means this setting applies to every Git project you work on from this computer. Without --global, the command would only affect the current project.
If you want to use a different name for just one project (not recommended for most people), navigate into that project's folder and run the same command without --global:
git config user.name "Project-Specific Name"
Update your Git email address
Update the email Git associates with your commits by running:
git config --global user.email "your.email@example.com"
Use the email address you want to appear on your commits. This should typically match the email address on your GitHub account, though Git doesn't enforce that — it's just a field in the commit record. GitHub uses this email to link commits to your account when you push code, so mismatches can cause commits to appear as "unverified" or not connected to your profile.
If you have multiple GitHub accounts or use different emails for different projects, you can set a project-specific email the same way you would for the name — navigate to the project folder and run the command without --global.
Verify your changes took effect
After you've run the configuration commands, check that they stuck by running the lookup commands again:
git config --global user.name
git config --global user.email
The terminal should now print back the new values you just set. These settings are now active and will be used on all new commits you make from this computer. Make a test commit to confirm everything is working — create or edit a file, stage it with git add, and commit it with git commit -m "test". When you push that commit to GitHub, it should show your new name.
What happens to commits you already made
Changing your Git configuration does not rewrite your old commits. Any commits you made before the change will still show the old name and email they were created with. This is by design — Git treats commit history as permanent, and rewriting it can cause problems if other people have already pulled your code.
If you need to update the author information on old commits, that's a more complex operation involving Git's rebase feature. For most people, it's simpler to just accept that old commits show the old name and move forward with the new configuration for future work.
Frequently Asked Questions
Does changing my Git username change my GitHub account username?
No. Your Git configuration is stored on your computer and controls what name appears on commits. Your GitHub account username is separate and must be changed through the GitHub website settings. Changing one does not affect the other.
Why do my commits show a different name on GitHub than what I set in Git?
GitHub links commits to your account using the email address in the commit. If the email doesn't match any email on your GitHub account, the commit appears as unverified and may show a generic avatar instead of your profile picture. Make sure your Git email matches one of the emails listed in your GitHub account settings.
Can I use different usernames for different projects?
Yes. Navigate into a project folder and run git config user.name "Name" without the --global flag. That project will use the local setting instead of the global one. This is useful if you work on both personal and work projects from the same computer.
What if I don't remember what username I set?
Run git config --global user.name to see the current global setting. If you want to see all your Git configuration settings at once, run git config --global --list. This prints every global setting Git has stored.
Do I need to restart my terminal after changing my username?
No. Git reads the configuration file fresh with each command, so changes take effect when ready. Any new commits you make after running the configuration command will use the new name.