The two commands that change your Git username

Git stores your username in a configuration file on your computer. To change it, you run one of two commands in Git Bash, depending on whether you want the change to affect only one project folder or all projects you work on.

The command for a single project is git config user.name "Your New Name". Run this command inside the project folder, and Git will remember that name only for commits you make in that folder.

The command for all projects on your computer is git config --global user.name "Your New Name". The --global flag tells Git to save the name in your user account settings instead of in a single project folder. Any new project you work on will use this name unless you override it with the first command.

Key Takeaways

  • Use git config user.name "Your Name" to change your username for one project only.
  • Use git config --global user.name "Your Name" to change your username for all projects on your computer.
  • The name you set in Git Bash is what appears in your commit history and on platforms like GitHub, so use the name you want others to see.
  • You can check what username Git currently has stored by running git config user.name (or git config --global user.name for the global setting).

Step-by-step: changing your username for one project

Open Git Bash and navigate to the project folder where you want to change your username. If you are not sure how to navigate in Git Bash, type cd followed by a space, then drag the project folder into the Git Bash window and press Enter.

Once you are in the project folder, type the command exactly as shown: git config user.name "Your New Name". Replace "Your New Name" with the name you want to use. If your name has spaces or special characters, keep the quotation marks around it.

Press Enter. Git will not print a message saying the change worked — that is normal. To confirm the change took effect, type git config user.name and press Enter. Git will print back the name you just set.

Step-by-step: changing your username for all projects

Open Git Bash anywhere on your computer — you do not need to be in a project folder. Type the command exactly as shown: git config --global user.name "Your New Name". Replace "Your New Name" with the name you want to use for all your projects.

Press Enter. Like the project-level change, Git will not print a confirmation message. To verify the change, type git config --global user.name and press Enter. Git will print back the name you set.

This global setting now applies to every project folder on your computer, unless you override it by running the project-level command (without --global) inside a specific folder.

What name should you actually use

The name you set in Git is what shows up in your commit history and on platforms like GitHub, GitLab, or Bitbucket. If you are working on a team or publishing your code publicly, use a name you are comfortable with others seeing — usually your real name or a consistent username you use elsewhere.

If you are learning Git on your own computer and do not plan to share your code, you can use any name. Many people use their real name or a professional username so that when they later push code to a public repository, the history is already correct.

You can change your username as many times as you want. Each commit you make after the change will use the new name. Commits you made before the change will still show the old name in the history.

Checking what username Git currently has

To see what username Git is currently set to use for a single project, navigate into that project folder in Git Bash and type git config user.name. Git will print the name it has stored for that project.

To see your global username (the one that applies to all projects), type git config --global user.name from anywhere in Git Bash. If you have set a global username but not a project-specific one, Git will use the global name for commits in that project.

If you have never set a username at all, Git will print nothing or an error. In that case, run one of the change commands above before making your first commit.

Why Git asks for a username at all

Git records who made each commit so that when multiple people work on the same project, the history shows who changed what and when. Even if you are working alone, Git uses the username to mark your commits. This information becomes part of the permanent record of your project.

The username Git stores locally on your computer is separate from your username on GitHub or other platforms. You can set any name in Git Bash — it does not have to match your GitHub account name, though it usually makes sense to keep them consistent so people know it is you.

Frequently Asked Questions

Does changing my Git username affect commits I already made?

No. Commits you made before the change will still show the old username in the history. Only new commits you make after the change will use the new username. If you need to change the author of old commits, that requires a more advanced Git operation called rebasing, which is beyond the scope of changing your current username.

What if I set a project-level username and a global username?

Git uses the project-level username for commits in that specific folder. The global username is a fallback that Git uses for all other projects. If you set both, the project-level one takes priority.

Can I use a different username on GitHub than the one I set in Git Bash?

Yes. The name in Git Bash is what appears in your commit history. GitHub shows your GitHub account username separately. When you push commits to GitHub, both names are visible — the commit author (from Git Bash) and your GitHub account name. Most people keep them the same to avoid confusion.

Do I need to set my email in Git Bash too?

Yes, but that is a separate step. Git stores both a username and an email address with each commit. You set your email the same way: git config user.email "your@email.com" for a single project, or git config --global user.email "your@email.com" for all projects.

What if Git Bash says "command not found"?

Make sure you have Git installed on your computer and that Git Bash is the terminal you are using, not the regular Windows Command Prompt. If you are using Command Prompt by mistake, the Git commands will not work. Open Git Bash specifically — you can find it by searching your computer for "Git Bash".