Change your Git username with a single command
Your Git username is the name that appears on every commit you make. To change it, open your terminal or command prompt and run one of two commands, depending on whether you want the change to affect only your current project or all projects on your computer.
For a single project, navigate into that project's folder and run: git config user.name "Your New Name". For all projects on your computer, add the --global flag: git config --global user.name "Your New Name". Replace "Your New Name" with the name you want to display.
The change takes effect when ready. Your next commit will show the new name. Previous commits keep their old names — changing your username does not rewrite history.
Key Takeaways
- Use git config user.name "Your Name" to change the username for one project only.
- Use git config --global user.name "Your Name" to change the username for all projects on your computer.
- The change takes effect on your next commit and does not alter commits you have already made.
- You can check your current username by running git config user.name (or add --global to see the global setting).
- Your Git username is separate from your GitHub, GitLab, or Bitbucket account name — changing one does not change the other.
The difference between local and global username changes
A local change affects only the project folder you are currently in. This is useful if you work on multiple projects and want different names on different ones — for example, using your full name for work projects and a nickname for personal ones.
A global change affects every project on your computer. It sets a default that applies unless you override it with a local change. Most people set a global username once and leave it, then use local changes only when they need an exception.
If you have set both a global and a local username, Git uses the local one. You can always check which name is currently active by running git config user.name from inside your project folder.
Where to run the command
On Windows, open Command Prompt or PowerShell. On Mac or Linux, open Terminal. Navigate to your project folder using cd — for example, cd ~/Documents/my-project — then type the command.
If you are changing the global username and do not care which folder you are in, you can run the command from anywhere. The --global flag tells Git to update your system-wide settings, not the current project.
If you are unsure whether you are in the right folder, run pwd (on Mac or Linux) or cd (on Windows) to see your current location. You should see the project folder name in the path.
Checking your current username before you change it
Before making a change, you may want to see what your username is set to right now. Run git config user.name to see the local username for your current project, or git config --global user.name to see the global default.
If nothing appears after you run the command, no username is set at that level. Git will then look at the next level — if no local username exists, it uses the global one. If neither exists, Git will prompt you to set one the next time you try to commit.
Your Git username versus your account name on GitHub, GitLab, or Bitbucket
Your Git username (the name in your commits) is separate from your account username on platforms like GitHub or GitLab. Changing your Git username does not change your account name on those services, and vice versa.
This separation exists because Git is a tool that runs on your computer, while GitHub and similar services are websites where you push your code. Your Git username is what appears in the commit history; your account username is what you use to log in and what appears in your profile URL.
If you want your commits to show a different name than your account username, that is fine — just set your Git username to whatever you prefer. The two do not have to match.
Changing your email address at the same time
Git also tracks an email address with each commit. You can change it the same way: git config user.email "your-email@example.com" for a local change, or git config --global user.email "your-email@example.com" for a global change.
Many people set both their username and email at the same time when they first set up Git. If you are changing one, you may want to check the other and update it if needed. Run git config user.email to see what is currently set.
Frequently Asked Questions
Will changing my username affect commits I already made?
No. Previous commits keep the username that was set when you made them. Only new commits will show the new username. If you need to change the name on old commits, that requires rewriting history, which is a more advanced task.
Do I need to change my username on GitHub or GitLab too?
No. Your Git username and your account username are separate. Changing one does not affect the other. However, if you want your commits to show a name that matches your profile on those services, you can set your Git username to match your account name.
What if I set a global username but want a different one for one project?
Run the local command in that project's folder: git config user.name "Different Name" (without --global). Git will use the local name for that project and the global name for all others.
Can I use special characters or spaces in my username?
Yes. Wrap your name in quotes if it contains spaces: git config user.name "Jane Doe". Special characters like hyphens and apostrophes work fine inside quotes.
What if I do not remember running git config before?
You may have set it during Git installation or when you first cloned a repository. Run git config --global user.name to check. If nothing appears, no global username is set, and you can create one now.