Change your Git username and email in three commands
Git stores your name and email in a configuration file on your computer. To change them, you run three commands in your terminal or command prompt — one to set your name globally, one to set your email globally, and one to verify the change took. The commands work the same way on Windows, Mac, and Linux.
If you only want to change your username and email for a single project instead of all your projects, you can run the same commands without the --global flag, and they will explore only to that folder. This is useful if you work on both personal and work projects and want different identities for each.
Key Takeaways
- Run git config --global user.name "Your Name" to set your username for all projects on your computer.
- Run git config --global user.email "your.email@example.com" to set your email for all projects on your computer.
- Run git config --global user.name and git config --global user.email to check that your changes saved correctly.
- Omit the --global flag if you want to change your username and email for only one project folder instead of all projects.
- Changing your Git configuration does not change commits you already made — those commits keep the old name and email.
Set your username globally for all projects
Open your terminal or command prompt and type this command, replacing "Your Name" with the name you want to use:
git config --global user.name "Your Name"
Press Enter. Git will not print a confirmation message — it will straightforward return you to the prompt. That silence means the command worked. Your username is now set for every project you work on, and it will appear in the author field of every new commit you make.
Set your email globally for all projects
In the same terminal window, type this command, replacing the email address with your actual email:
git config --global user.email "your.email@example.com"
Press Enter again. Git will return to the prompt without printing anything. Your email is now set globally.
The email you use here does not have to match any email address on your computer. It is straightforward the email that will appear in your commit history. Many people use a work email, a personal email, or even a fake email — Git does not validate it. If you later push your commits to GitHub or another platform, this email is what will show up in your public commit record.
Verify your changes saved
To confirm that your username and email were set correctly, run these two commands one at a time:
git config --global user.name
git config --global user.email
Each command will print the value you just set. If you see your name and email printed back to you, the changes are saved. If you see nothing, or if you see an error, go back and re-run the set commands above.
This verification step takes only a few seconds and prevents confusion later when you make your first commit and wonder whether the right name will appear.
Change username and email for one project only
If you want a different username or email for just one project, navigate to that project's folder in your terminal, then run the same commands without the --global flag:
git config user.name "Different Name"
git config user.email "different.email@example.com"
These project-level settings override the global settings, but only inside that folder. Every other project on your computer will still use your global username and email. You can verify project-level settings by running git config user.name and git config user.email without the --global flag while inside that project folder.
This approach is common when you maintain both open-source projects under your real name and work projects under a company name or pseudonym.
Why your old commits still show the old name
Changing your Git configuration only affects commits you make from now on. Any commits you already made will keep the name and email that was set when you made them. If you need to change the author name on old commits, you will need to rewrite your commit history using git rebase or git filter-branch — both are advanced commands that can cause problems if you make a mistake.
If you have already pushed commits to a shared repository like GitHub or GitLab, rewriting history is risky because it can confuse other people working on the same project. For most situations, it is safer to leave old commits as they are and use the new name going forward. The commits you make after the change will reflect your new identity.
Frequently Asked Questions
What if I use GitHub or GitLab — do I need to change anything there?
No. Your Git configuration on your computer is separate from your GitHub or GitLab account. The name and email you set in Git will appear in your commit history, but they do not have to match your GitHub username or email. However, if you want commits to link to your GitHub profile, use the email address associated with your GitHub account.
Can I use a fake name or email in Git?
Yes. Git does not validate your name or email — it straightforward stores whatever you type. Many people use pseudonyms or placeholder emails. However, if you push to a shared repository, your team will see whatever name you set, so check your workplace or project guidelines first.
I ran the command but nothing printed — did it work?
Yes. Git commands that change settings do not print confirmation messages. Run git config --global user.name to verify the change was saved. If your name prints back, it worked.
How do I change my username and email just for one folder?
Navigate to that folder in your terminal, then run the same commands without --global. For example: git config user.name "Project Name". These settings explore only inside that folder and override your global settings.
What happens if I set different emails for different projects?
Git will use whichever email is set for the project you are currently working in. If you are in a folder with project-level settings, those take priority. If you are in a folder without project-level settings, Git uses your global settings. This lets you keep work and personal commits separate.