Change your username for a single repository

The fastest way to change your Git username is to run a command inside the folder where your code lives. Open your terminal or command prompt, navigate to that folder, and run this command:

git config user.name "Your New Name"

Replace "Your New Name" with whatever name you want to appear in your commit history. This change only affects that one repository — your other projects keep their old username. You can verify the change worked by typing git config user.name, which will print back the name you just set.

This approach is useful when you work on multiple projects and want different names for different ones, or when you only need to fix the username for commits going forward in a single project.

Change your username for all repositories on this computer

If you want every repository on your computer to use the same username, set it globally instead. Run this command from anywhere (you do not need to be inside a repository folder):

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

The --global flag tells Git to remember this name for every project you work on from now on. Any new commits you make will use this name automatically. Existing commits in past projects keep their old names — changing the global setting does not rewrite history.

You can check your global username at any time by typing git config --global user.name. If you ever need to change it again, just run the same command with a different name.

Key Takeaways

  • Use git config user.name "Name" inside a repository folder to change the username for only that project.
  • Use git config --global user.name "Name" to change the username for all repositories on your computer.
  • Changing your username only affects new commits you make going forward, not commits you made in the past.
  • You can check what username is currently set by running the same command without a name at the end.
  • If you set both a global username and a repository-specific username, Git uses the repository-specific one for that project.

Understanding where your username appears

Your Git username shows up in the commit history whenever you make a commit. When someone runs git log or looks at the project on GitHub, GitLab, or another platform, they see your name attached to each commit you made. This is different from your email address, which Git also stores but does not display as prominently in most interfaces.

The username you set in Git is purely local — it only matters on your computer and in the repositories you push to. If you push to GitHub or another service, that platform may have its own username or account name, but your Git username is what appears in the actual commit record.

Changing your email address at the same time

Git also stores an email address with each commit. You can change it the same way you change your username. For a single repository, run:

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

For all repositories on your computer, run:

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

Like the username, changing your email only affects commits you make from this point forward. If you want to change the email on commits you already made, you need a different approach — you would need to rewrite the commit history, which is more complex and should only be done if you are certain no one else is using those commits.

When you work on multiple computers

If you use Git on a laptop, a desktop, and a work computer, each one has its own Git configuration. Changing your username on your laptop does not change it on your desktop. You need to run the same command on each computer where you want the change to take effect.

This is why many people set a global username on each computer they use — so they do not have to remember to configure it for every new project. If you use the same computer for personal and work projects, you might set different usernames in different folders by using the repository-level command instead of the global one.

Fixing commits with the wrong username

If you made commits with the wrong username and want to change them, you have two options. The simplest is to leave them as they are — old commits stay in the history with the name they had when you made them. This is usually fine and is what most people do.

If you must change the username on past commits, you can use git rebase or git filter-branch, but both of these rewrite your commit history. This can cause problems if other people are working from your repository, so only do this if you are certain it is safe. Most teams consider it better to leave the history alone and just use the correct username going forward.

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. You can have any Git username you want locally, but GitHub shows your account name on the platform. If you push commits with a different Git username, GitHub still attributes them to your account based on the email address in the commit.

What if I set both a global and a local username?

Git uses the repository-specific username for that project and ignores the global one. This is useful if you want one name for most projects but a different name for a specific folder — set the global one, then override it in that one repository.

Can I see what username I currently have set?

Yes. Type git config user.name to see your repository-level username, or git config --global user.name to see your global username. If nothing prints, that setting has not been configured yet.

Do I need to restart anything after changing my username?

No. The change takes effect when ready. Your next commit will use the new username without restarting your terminal, your editor, or anything else.

What name should I use?

Use whatever you want — your real name, a nickname, a pseudonym, or anything else. Git does not check or validate the name. Most people use their real name or a professional name so others know who made each commit.