The Two Ways to Change Your Git Username
Your Git username is the name that appears on every commit you make. You can change it in two places: globally (so it applies to every repository on your computer) or locally (so it applies only to one specific project folder). Most people change it globally the first time, then override it locally only when they need a different name for a particular project.
The commands are nearly identical — the difference is a single flag. Global changes use git config --global, and local changes use git config without the --global flag. Both take effect when ready and do not require you to restart anything.
Key Takeaways
- Use git config --global user.name "Your Name" to change your username everywhere on your computer, or git config user.name "Your Name" inside a project folder to change it for that project only.
- The username you set in Git is separate from your GitHub username or GitLab username — changing one does not change the others.
- You can check what username Git is currently using by typing git config user.name (local) or git config --global user.name (global).
- Changes take effect on your next commit — existing commits keep the username they were made with.
Changing Your Username Globally
Open your terminal and type this command, replacing "Your Name" with the name you want to appear on your commits:
git config --global user.name "Your Name"
Then press Enter. There is no confirmation message — if the command returns you to a blank prompt with no error, it worked. The name is now set for every repository you work with on this computer, unless you override it locally in a specific folder.
If you want to verify the change took, type git config --global user.name and press Enter. Git will print back the name you just set.
Changing Your Username for One Project Only
Navigate into the project folder where you want a different username. Use cd to move to that folder — for example, cd ~/Documents/my-project — then type:
git config user.name "Your Name"
Notice there is no --global flag this time. Press Enter. This username now applies only to commits you make inside this folder. When you work in other folders, Git will use your global username instead.
To check what username is set locally in this folder, type git config user.name and press Enter. If you set a local username, it will print that. If you did not, it will print your global username.
What Happens to Commits You Already Made
Changing your username does not rewrite commits you already made. Those commits keep the username they were created with. Only new commits going forward will use the new name.
If you need to change the username on past commits, that requires rewriting Git history, which is a separate and more complex process. For most situations, you only need to change the username for future work.
Git Username vs. GitHub or GitLab Username
Your Git username (what you set in the terminal) is not the same as your GitHub username, GitLab username, or any other service username. They are completely separate. Changing your Git username does not change your account on GitHub or anywhere else.
When you push commits to GitHub or GitLab, the service shows the Git username from the commit itself, not your account username. So if you set your Git username to "Alice Smith" but your GitHub account is "asmith42", commits will show as authored by "Alice Smith" even though they came from your asmith42 account.
Fixing a Typo or Changing Your Mind
If you made a mistake or want to use a different name, just run the command again with the correct name. The new name replaces the old one when ready.
To change your global username again, type git config --global user.name "Correct Name". To change a local username in a specific folder, navigate into that folder and type git config user.name "Correct Name". There is no need to undo anything first — the new command straightforward overwrites the old value.
Frequently Asked Questions
Can I use a different username in different folders?
Yes. Set a global username that applies everywhere, then use the local command (without --global) inside any folder where you want a different name. Git checks the local setting first, then falls back to the global one.
Does my Git username have to match my real name?
No. You can use any text you want — a nickname, a pseudonym, or a business name. It is purely what appears on your commits. Some people use their real name, others use a handle or initials.
What if I set the wrong username and already made commits?
The old commits keep the wrong name. Change your username now for future commits. If you need to fix the author on past commits, you will need to use git rebase or git filter-branch, which are advanced operations.
Do I need to set an email address too?
Yes, Git also requires an email address. Use git config --global user.email "your@email.com" to set it globally, or git config user.email "your@email.com" to set it locally in one folder. Both the username and email appear on every commit.
Will changing my Git username affect my GitHub account?
No. Your Git username and your GitHub account are separate. Changing one does not change the other. You can have any Git username you want and still push to your GitHub account — GitHub identifies you by your credentials, not by the Git username in the commit.