Change your Git username with a single command

You can change your Git username globally (for all repositories on your computer) or locally (for just one repository). The command is the same either way — you only add a flag to choose the scope.

To change your username globally, open your terminal or command prompt and type:

git config --global user.name "Your New Name"

To change it for just one repository, navigate into that folder first, then type the same command without the --global flag:

git config user.name "Your New Name"

The change takes effect when ready. Any commits you make after this point will show the new name.

Key Takeaways

  • Use git config --global user.name "Your Name" to change your username for all repositories on your computer.
  • Use git config user.name "Your Name" (without --global) inside a specific folder to change the username for just that repository.
  • The change affects new commits only — old commits keep the name they were made under.
  • You can check what username Git is currently set to by typing git config user.name (or git config --global user.name for the global setting).

Global versus local username changes

A global change affects every repository on your computer. This is useful if you want the same name on all your projects, or if you are switching to a new name permanently. Once you set it globally, you do not have to think about it again.

A local change affects only the repository you are currently in. This is useful if you work on multiple projects under different names — for example, if you contribute to open-source projects under one name and work on private projects under another. You can set a different username for each folder.

If you set both a global and a local username, Git uses the local one for that repository. The global setting acts as a fallback for any repository that does not have its own local setting.

Checking your current username

Before you change your username, you may want to see what it is currently set to. Type:

git config user.name

This shows the local username for the current repository. To see the global username instead, type:

git config --global user.name

If nothing appears, Git does not have a username set at that level yet. The next time you make a commit, Git will either use a username from the other level (global or local) or prompt you to set one.

What happens to commits you already made

Changing your username does not change the author name on commits you have already made. Those commits keep the name they were created under. Only new commits going forward will show the new username.

If you need to change the author name on old commits, that requires a more complex process called rewriting history. This is rarely necessary unless you are fixing a mistake on a repository only you use. If you have already pushed commits to a shared repository (like on GitHub), rewriting history can cause problems for other people working on the project.

Setting up Git for the first time

If you have never set a Git username before, you will see an error or warning the first time you try to make a commit. Git needs a name and email address to record who made each change.

Set both at once by typing:

git config --global user.name "Your Name"

git config --global user.email "your.email@example.com"

Use the --global flag so you only have to do this once. After that, every repository on your computer will have a default author name and email.

Usernames on GitHub, GitLab, and other platforms

Your Git username (the name that appears in commits) is separate from your account username on GitHub, GitLab, Bitbucket, or other hosting platforms. Changing your Git username does not change your account name on those sites, and vice versa.

Your Git username is purely local — it only affects what name appears in the commit history on your computer. When you push commits to GitHub or another platform, the platform may display your account name, your Git username, or both, depending on how it is configured.

If you want to change your account name on GitHub itself, that is a separate process done in your account settings on the GitHub website.

Frequently Asked Questions

Can I use a different username for different repositories?

Yes. Navigate into each repository folder and run git config user.name "Name" without the --global flag. Each repository will then use its own local username, overriding the global one.

What if I set the wrong username and already made commits?

New commits will use the corrected username. Old commits keep their original author name. If the commits are only on your computer and you have not pushed them yet, you can rewrite them, but this is complex and unnecessary unless you are fixing a serious mistake.

Does changing my Git username affect my GitHub account?

No. Your Git username is local to your computer. Your GitHub account name is separate and does not change unless you change it in GitHub's settings. However, GitHub may display your account name alongside your Git username in some places.

How do I set a username and email at the same time?

Run both commands in sequence: git config --global user.name "Your Name" and then git config --global user.email "your.email@example.com". You can also edit your Git configuration file directly if you prefer.

What if I want to use my full name but Git is showing only my first name?

Run git config --global user.name "Your Full Name" with your complete name in quotes. Git will use exactly what you type, so include spaces and any other characters you want to appear in commits.