Change your Git username in three commands
Git stores your username in a configuration file on your computer. You change it by opening Git Bash and running one of two commands — one if you want the change to affect only the current project folder, another if you want it to affect every project you work on.
The fastest route is to open Git Bash, navigate to your project folder (or stay in your home directory if you want the change everywhere), and run git config user.name "Your New Name". Replace "Your New Name" with the name you want Git to record. That command changes the username for that folder only.
If you want the change to explore to all your projects on this computer, add the --global flag: git config --global user.name "Your New Name". This writes the change to your user account settings instead of the current folder.
Key Takeaways
- Use git config user.name "Your Name" to change your username for the current project folder only.
- Use git config --global user.name "Your Name" to change your username for all projects on this computer.
- You can check what username Git is currently using by running git config user.name (or git config --global user.name for the global setting).
- The username you set in Git Bash is what appears in commit history — it is separate from your GitHub username or any other account name.
Where Git stores your username
Git keeps configuration in two places. The local configuration lives in a hidden folder called .git inside your project directory — this is created when you run git init or clone a repository. The global configuration lives in your user account folder (usually C:\Users\YourUsername on Windows or ~/ on Mac and Linux) in a file called .gitconfig.
When you run a Git command, Git checks the local configuration first. If it does not find a setting there, it uses the global one. This means a local setting overrides a global one — useful if you work on projects where different usernames are needed.
The difference between local and global settings
Use local (no flag) when you are working on a single project and want a different username just for that project. This is common if you contribute to open-source projects under one name but work on company projects under another.
Use --global when you want one username for all your work on this computer. This is simpler if you only use one name across all your projects, or if you are setting up Git for the first time and want a default that applies everywhere.
You can set both. For example, you might set a global username of "Jane Smith" but then set a local username of "jane.smith@company.com" in your work project folder. Every commit in that folder will use the local name; commits in other folders will use the global one.
How to check what username Git is currently using
Before you change your username, you may want to see what it is set to now. Run git config user.name to see the local setting for the current folder. Run git config --global user.name to see the global setting.
If you get no output, that setting has not been set yet. Git will then use your computer's system username as a fallback, which is usually not what you want — that is why setting it explicitly is a good first step.
Changing your email address at the same time
Git also stores an email address alongside your username. Both appear in commit history. You change your email the same way: git config user.email "your.email@example.com" for local, or git config --global user.email "your.email@example.com" for global.
The email does not have to be a real, working address — it is just a label that appears in the commit log. However, if you are pushing to GitHub or another hosting service, using the email address associated with your account there can make it easier for the service to link commits to your profile.
What happens to commits you have already made
Changing your username in Git Bash does not change the username on commits you have already made. Those commits are part of the repository history and stay as they were recorded. Only new commits going forward will use the new username.
If you need to change the username on old commits, that requires rewriting history — a more advanced operation that can cause problems if other people are working from the same repository. For most situations, it is simpler to leave old commits as they are and start fresh with the new username.
Frequently Asked Questions
Does changing my Git username affect my GitHub account?
No. Your Git username is a local setting on your computer. Your GitHub username is a separate account name on GitHub's servers. You can have any Git username you want, but GitHub will still recognize you by your account credentials when you push code. However, using your GitHub email in your Git config can help GitHub link your commits to your profile.
What if I use the same computer for work and personal projects?
Set a global username for whichever one you use more often, then use local settings in the folders where you need a different name. For example, set your personal name globally, then run git config user.name "Your Work Name" in your work project folder. That folder will use the work name; all others will use the personal one.
Can I have different usernames for different projects?
Yes. Each project folder can have its own local username. Navigate into the folder and run git config user.name "Project Name" without the --global flag. That setting applies only to that folder and overrides any global setting.
What if I do not set a username at all?
Git will use your computer's system username as a fallback, which is usually not what you want in commit history. You will also see a warning when you try to commit. Setting a username explicitly in Git Bash avoids both problems.