The fastest way to change your Git username
You change your Git username by running a single command in your terminal or command prompt. The command you use depends on whether you want the change to affect only one repository (the folder where your code lives) or all repositories on your computer.
For a single repository, navigate into that folder and run: git config user.name "Your New Name". For all repositories on your machine, add the --global flag: git config --global user.name "Your New Name". That's the entire process — no restart needed, no hidden settings to find.
Key Takeaways
- Use git config user.name "Your Name" to change the username for one repository only.
- Use git config --global user.name "Your Name" to change the username for every repository on your computer.
- The change takes effect when ready on your next commit — you do not need to restart anything.
- You can verify the change worked by running git config user.name (without --global) or git config --global user.name to see what is currently set.
Changing the username for just one repository
Open your terminal or command prompt and navigate to the folder containing the repository you want to change. On Mac or Linux, use cd /path/to/your/repository. On Windows, use cd C:\path\to\your\repository or open the folder in File Explorer, right-click inside it, and select "Open in Terminal" or "Git Bash Here" if you have Git Bash installed.
Once you are inside the repository folder, type: git config user.name "Your New Name" and press Enter. Replace "Your New Name" with the name you want to appear on your commits. This change affects only this one repository — all other repositories on your computer keep their old username.
This approach is useful if you work on multiple projects and want different names on different ones — for example, a professional name on work repositories and a personal name on hobby projects.
Changing the username for all repositories on your computer
If you want every repository you work with to use the same username, use the --global flag. Open your terminal or command prompt anywhere (you do not need to be inside a repository folder) and type: git config --global user.name "Your New Name". Press Enter and you are done.
This sets a default username that Git will use for every repository on your computer unless you override it with a repository-specific setting (the method described above). Most people use this approach because they work under one name across all their projects.
Verifying the change took effect
To check what username is currently set for a single repository, navigate into that repository folder and run: git config user.name. Git will print the name that is currently active for that repository.
To check your global username, run: git config --global user.name. This shows the default name that will be used on any new commits unless you have set a different name for that specific repository.
If you see nothing printed, no username has been set yet at that level. Your next commit will fail with an error asking you to set a username before proceeding.
What happens to commits you already made
Changing your username does not change the author name on commits you have already made. Those commits keep the name that was set when you created them. Only new commits going forward will use the new username.
If you need to change the author name on commits you have already made, that requires rewriting your repository history — a more complex process that can cause problems if other people are working on the same code. For most situations, it is simpler to leave old commits as they are and use the correct name going forward.
Changing your email address at the same time
Git also stores an email address with each commit. You can change it the same way you change your username. For a single repository, run: git config user.email "your.email@example.com". For all repositories, run: git config --global user.email "your.email@example.com".
Many people set both the username and email at the same time when they first set up Git, or when they switch jobs or accounts. The email address is what platforms like GitHub and GitLab use to link commits to your account, so using the email address associated with your account on those platforms is important if you want your contributions to show up in your profile.
Frequently Asked Questions
Do I need to restart Git or my computer after changing my username?
No. The change takes effect when ready. Your next commit will use the new username without any restart or reload needed.
Will changing my username affect commits I already pushed to GitHub or another service?
No. Commits that are already pushed keep the author name they had when you created them. Changing your username only affects new commits you make going forward. The service (GitHub, GitLab, etc.) will still link old commits to your account based on the email address, but the author name displayed will be whatever you set when you made the commit.
What if I set a repository-specific username but also have a global username?
Git uses the repository-specific setting first. If you have set a username for that particular repository, it will use that name on commits. If you have not set one for that repository, it falls back to your global username. This lets you override the global setting for specific projects.
Can I use special characters or spaces in my username?
Yes. Wrap your name in quotes if it contains spaces or special characters: git config user.name "Mary O'Brien". Git will store and display whatever you put in the quotes.
How do I undo a username change?
Set it to a different name using the same command. There is no "undo" — you straightforward run the command again with the name you want instead. If you want to remove a repository-specific setting and go back to using your global username, run: git config --unset user.name (without the --global flag) inside that repository.