Yes, you can change your Git username, and the method depends on whether you want to change it globally or just for one project
Git stores your username in a configuration file on your computer. You can update it using the command line in about two minutes. The change affects commits you make going forward — it does not rewrite commits you have already made, though that is possible if you need it.
Most people change their username globally, which means every project on your computer uses the new name. You can also change it for a single project if you work on multiple accounts or want different names for work and personal projects.
Key Takeaways
- Global username changes affect all projects on your computer and are made with the --global flag in the command line.
- Project-specific changes affect only one folder and are made without the --global flag, inside that project's folder.
- You need to open a terminal or command prompt — the method varies slightly between Windows, Mac, and Linux, but the Git commands are identical.
- The change takes effect when ready for new commits; old commits keep the name they were made under.
- Your Git username is separate from your GitHub, GitLab, or Bitbucket account name, though many people use the same name for both.
Change your username globally across all projects
Open a terminal or command prompt on your computer. On Mac or Linux, search for "Terminal" in your applications. On Windows, search for "Command Prompt" or "PowerShell".
Type this command and press Enter, replacing "Your Name" with the name you want to use:
git config --global user.name "Your Name"
That is all. The change is saved when ready. Every new commit you make on any project will show this name as the author. You can verify it worked by typing git config --global user.name and pressing Enter — it will print back the name you just set.
Change your username for one project only
Open a terminal or command prompt and navigate to the folder where your project lives. On Mac or Linux, use cd /path/to/your/project. On Windows in Command Prompt, use cd C:\Users\YourName\path\to\your\project.
Once you are inside the project folder, type this command without the --global flag:
git config user.name "Your Name"
This sets the username only for that project. If you have a global username set, this project will override it. Other projects on your computer will still use the global name. This is useful if you work on both personal and work projects and want different names for each.
Check what username is currently set
To see your global username, type:
git config --global user.name
To see the username for the current project only, type:
git config user.name
If you have set a project-specific username, it will print that. If you have not, Git will print nothing — which means it will use your global username for commits in that project.
Why your Git username is different from your GitHub or GitLab name
Your Git username is a local setting on your computer that appears in your commit history. Your GitHub, GitLab, or Bitbucket account name is what you log in with on those websites. They are separate things, though many people use the same name for both to avoid confusion.
If you change your Git username but not your account name on GitHub or another platform, your commits will still push to your account — the platforms match commits by the email address in your Git configuration, not the name. However, the name that appears in the commit history will be whatever you set locally.
Rewriting old commits with a new username
Changing your Git username only affects commits you make from that point forward. If you want to change the author name on commits you have already made, you need to rewrite the commit history. This is possible but should only be done on branches that you have not yet pushed to a shared repository, because rewriting history can cause problems for other people working on the same code.
If you need to rewrite commits on a branch you have already pushed, talk to your team first. The process involves using git rebase or git filter-branch, which are more advanced tools. For most situations, it is simpler to leave old commits as they are and use the new username going forward.
Troubleshooting: commits still show the old name
If you changed your username but your next commit still shows the old name, you may have set the username in the wrong scope. Check whether you set it globally or locally, and whether you are in the right project folder when making the commit.
Also check that you did not set a username in your system environment variables or in a .gitconfig file in your home directory — these can override your command-line settings. On Mac and Linux, you can view the contents of your .gitconfig file by typing cat ~/.gitconfig in the terminal.
Frequently Asked Questions
Does changing my Git username affect commits I already made?
No. Old commits keep the name they were made under. Only new commits going forward will use the new username. If you need to change the author name on old commits, you must rewrite the commit history, which is an advanced step and should only be done on branches you have not shared with others.
Will changing my Git username log me out of GitHub or GitLab?
No. Your Git username is a local setting on your computer. It does not affect your login to GitHub, GitLab, Bitbucket, or any other platform. Those sites match commits by email address, not by the name field in Git.
Can I use different usernames for different projects?
Yes. Set a global username that you use most of the time, then navigate to any project folder and use git config user.name "Different Name" without the --global flag. That project will use the different name while all others use the global one.
What if I set the username wrong and want to change it again?
Use the same command with the correct name. Type git config --global user.name "Correct Name" to overwrite the global setting, or git config user.name "Correct Name" inside a project folder to overwrite a project-specific setting.
Is my Git username the same as my email in Git?
No, they are separate. Your Git username is the name that appears as the author of commits. Your Git email is a separate setting that you configure with git config --global user.email "your@email.com". Both are stored locally on your computer and both appear in your commit history.