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 use.

The change takes effect when ready. Any commit you make after running the command will show your new username. Commits you made before the change will still show the old username — changing your Git 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 affects only new commits; old commits keep their original username.
  • You can check your current username by running git config user.name (or add --global to see the global setting).

The difference between global and local changes

A global change affects every Git project on your computer. This is useful if you want one username across all your work — for example, if you use the same computer for personal and work projects but want them all under your name. Once you set a global username, you do not have to configure it again unless you want to change it.

A local change affects only the current project. This is useful if you work on multiple projects that need different usernames — for example, if you contribute to an open-source project under one name and work on a company project under another. Local settings override global settings, so if you have both, Git uses the local one for that project.

If you are not sure which one you need, start with global. You can always override it for a specific project later by running the local command inside that project's folder.

How to check your current username

Before you change your username, you may want to see what it is set to right now. Run git config user.name to see the local username for your current project. If nothing appears, no local username is set.

To see your global username, run git config --global user.name. This shows the username Git will use for any project that does not have its own local setting. If you have set both a global and a local username, the local one takes priority.

Changing your email address at the same time

Your Git username and your Git email address are separate settings. Many people change both at once. The command for email is almost identical: git config user.email "your.email@example.com" for a single project, or git config --global user.email "your.email@example.com" for all projects.

The email you set here is what appears on your commits. It does not have to match any account you use elsewhere, though many people use their GitHub email or work email for consistency. Check what email you currently have set by running git config user.email or git config --global user.email.

What happens to commits you already made

Changing your Git username does not change the username on commits you made before the change. Those commits are part of your project's history, and Git does not rewrite history when you change your configuration.

If you need to change the username on old commits, that requires rewriting history with commands like git rebase or git filter-branch. This is more complex and can cause problems if other people are working on the same project. For most situations, it is simpler to leave old commits as they are and use your new username going forward.

Troubleshooting common issues

If you run the command and nothing seems to happen, that is normal — Git does not print a confirmation message. Run git config user.name to verify the change took effect.

If you get an error like "command not found", Git may not be installed on your computer, or your terminal does not know where to find it. On Windows, make sure you are using Git Bash or another terminal that has Git available. On Mac or Linux, you may need to install Git first.

If you set a local username but it is not showing up, make sure you ran the command inside the project folder. Git looks for configuration files in the project directory first, then in your home directory for global settings. Running the command in the wrong folder will not affect the project you are working on.

Frequently Asked Questions

Does changing my Git username affect my GitHub account?

No. Your Git username on your computer is separate from your GitHub username. Changing one does not change the other. However, if you push commits to GitHub, the name that appears on GitHub depends on both your Git username and which GitHub account you are signed into. For clarity, many people use the same name in both places.

Can I use different usernames for different projects?

Yes. Set a global username that you use most of the time, then run the local command inside any project that needs a different name. Git will use the local setting for that project and the global setting for everything else.

What if I want to change my username back to what it was before?

Run the same command with your old username. There is no "undo" button, but since the command is straightforward, you can change it as many times as you need. If you forgot what your old username was, you may not be able to recover it — Git does not keep a history of configuration changes.

Do I need to restart anything after changing my username?

No. The change takes effect when ready in your terminal. If you have other terminal windows open, they will also see the new setting. You do not need to restart your computer or any process.