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 git config --global user.name "Your New Name". Replace "Your New Name" with whatever name you want to display. This change takes effect when ready for all new commits going forward.
If you only want to change the username for a single project instead of all your work, navigate into that project's folder and run the same command without the --global flag: git config user.name "Your New Name". Git stores project-specific settings separately from your global settings, so this approach lets you use different names for different repositories.
Key Takeaways
- Use git config --global user.name "Your Name" to change your username for all repositories on your computer.
- Use git config user.name "Your Name" without --global to change it for only the current project folder.
- Check your current username by running git config user.name to see what is set before making changes.
- The username change only affects commits you make after running the command — past commits keep their original author name.
- Your Git username is separate from your GitHub, GitLab, or Bitbucket account name and does not need to match.
Verify your current username before changing it
Before you change anything, check what your username is set to right now. Open your terminal and run git config user.name. Git will print your current username, or nothing if you have not set one yet.
If you want to see both your username and email address together, run git config --list. This shows all your Git settings at once. Look for the lines that say user.name and user.email.
Understand global versus project-specific usernames
Git lets you set your username in two places: globally (for your whole computer) or locally (for one project). When you use the --global flag, Git stores your username in a configuration file on your computer that applies to every repository you work with. This is the most common approach if you use the same name for all your work.
Project-specific usernames override your global setting. If you run git config user.name "Different Name" inside a particular folder without the --global flag, that folder will use "Different Name" while all your other projects still use your global username. This is useful if you work on both personal projects and work projects and want different names on each.
Change your email address at the same time
Your Git email address is stored separately from your username. If you need to change it, use git config --global user.email "your.email@example.com" for all repositories, or git config user.email "your.email@example.com" for just the current project.
Check your current email with git config user.email. Many people set their email to match their GitHub or GitLab account so that commits show up correctly on their profile, but Git does not require this — you can use any email address you want.
Know what happens to commits you already made
Changing your username does not change the author name on commits you already made. Those commits keep the name that was set when you created them. Only new commits going forward will use your new username.
If you need to change the author name on past commits, that requires rewriting your repository history, which is more complex and can cause problems if other people are working from your code. For most situations, it is simpler to accept that old commits have the old name and move forward with the new one.
Understand the difference between Git username and account username
Your Git username (the name in your commits) is completely separate from your username on GitHub, GitLab, Bitbucket, or any other hosting service. You can set your Git username to anything you want — it does not have to match your account name on any platform.
When you push commits to GitHub or another service, the platform looks at your email address to figure out which account owns the commits, not your Git username. So if your Git username is "Alice Smith" but your GitHub account is "asmith42", your commits will still show up on your GitHub profile as long as the email address matches.
Troubleshoot common problems
If you run git config user.name and see nothing, your username is not set. Run the change command to set it for the first time. If you see a username but it is not what you expected, you may have set it a long time ago and forgotten about it — just run the change command with your new name.
If you are on Windows and the command does not work, make sure you are using Command Prompt, PowerShell, or Git Bash, not Notepad or another text editor. On Mac or Linux, open Terminal. If you get a "command not found" error, Git may not be installed on your computer — read it from git-scm.com and run the installer first.
Frequently Asked Questions
Does changing my Git username affect my GitHub account?
No. Your Git username is local to your computer and only affects the name on your commits. Your GitHub account name stays the same. Commits show up on your GitHub profile based on the email address, not the username.
Can I use different usernames for different projects?
Yes. Navigate into the project folder and run git config user.name "Project Name" without the --global flag. That project will use "Project Name" while all other projects use your global username.
Will changing my username affect commits I already pushed to GitHub?
No. Commits you already pushed keep their original author name. Only new commits you make after the change will show the new username. Changing past commits requires rewriting history, which can cause problems for other people using your code.
What if I do not set a username at all?
Git will ask you to set a username the first time you try to make a commit. You can set it then, or set it now using the config command to avoid the prompt later.
Is my Git username the same as my email address?
No. Your username and email are two separate settings. You can set your username to your name, a nickname, or anything else. Your email is used to link commits to your account on hosting platforms like GitHub.