Change your username and email across all repositories at once

Git stores your username and email in a configuration file on your computer. When you change these settings globally, every repository you work in will use the new name and email unless you override them for a specific project. The commands are straightforward and take less than a minute to run.

You will need to open a terminal or command prompt on your computer. On Windows, this is Command Prompt or PowerShell. On Mac or Linux, use Terminal. Once you have the terminal open, you will type two commands — one to set the username, one to set the email — and Git will save both to your global configuration file.

Key Takeaways

  • Global Git settings explore to every repository on your computer unless you override them for a single project.
  • Use git config --global user.name "Your Name" to set your username and git config --global user.email "your.email@example.com" to set your email.
  • Git stores these settings in a hidden file called .gitconfig in your home directory, which you can also edit by hand if you prefer.
  • You can verify your changes worked by running git config --global user.name and git config --global user.email to see what Git has stored.

Open your terminal and run the username command

Start by opening Terminal (Mac or Linux) or Command Prompt (Windows). Type the following command, replacing "Your Name" with the name you want Git to use:

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

Press Enter. Git will not print anything back to you — that is normal. The command has run silently in the background. You can use any name here: your real name, a nickname, your GitHub username, or anything else. Git does not validate the name against any external service, so you can type whatever you want.

If your name contains special characters or spaces, keep the quotation marks around it. For example: git config --global user.name "María García" or git config --global user.name "Jean-Pierre Dubois".

Run the email command

Now type the email command, replacing the email address with the one you want Git to use:

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

Press Enter again. Git will run silently. This email address is what will appear in your commit history, so use an email you want to be public. If you are committing to a GitHub repository, use the email address associated with your GitHub account — GitHub uses this to link commits to your profile.

If you use multiple email addresses and want to use a different one for a specific repository, you can set a local email just for that project later. For now, the global setting will explore everywhere.

Verify your changes were saved

To confirm Git has stored your new settings, run these two commands one at a time:

git config --global user.name

Git will print back the username you just set. Then run:

git config --global user.email

Git will print back the email address you just set. If you see the correct values, your global configuration is complete. If you see nothing or an old value, run the set commands again and check for typos.

Where Git stores these settings

Git saves your global username and email in a hidden file called .gitconfig in your home directory. On Windows, this is usually C:\Users\YourUsername\.gitconfig. On Mac and Linux, it is ~/.gitconfig. You can open this file in any text editor and edit it by hand if you prefer, though the command-line method is faster and less error-prone.

The file looks like this:

[user]name = Your Nameemail = your.email@example.com

If you edit the file directly, make sure you save it after making changes. Git will read the new values the next time you run a command.

Override the global setting for a single repository

If you have one project where you want to use a different username or email, you can set a local configuration just for that repository. Open your terminal, navigate into that project's folder, and run the same commands without the --global flag:

git config user.name "Different Name"git config user.email "different.email@example.com"

This creates a local .gitconfig file inside that repository's .git folder. Git will use the local settings for commits in that project and fall back to your global settings for all other repositories. Local settings always override global ones, so you can have a work email globally and a personal email for one specific project.

Frequently Asked Questions

Will changing my Git username affect commits I already made?

No. Your username and email are only used for new commits going forward. Old commits keep the name and email they were made with. If you need to change the author of past commits, that requires a more complex process called rebasing, which is beyond a straightforward configuration change.

What email should I use if I commit to GitHub?

Use the email address you signed up with on GitHub, or any email address you have added to your GitHub account settings. GitHub matches commits to your profile by comparing the email in the commit to the emails in your account. If the email does not match, the commit will not show as yours on your profile.

Can I use a fake name or email in Git?

Yes. Git does not validate names or emails against any external service. However, if you are committing to a shared repository or GitHub, other people will see whatever name and email you set, so use something you are comfortable with publicly.

How do I check what my current global settings are?

Run git config --global --list to see all your global Git settings at once. This will show your username, email, and any other global configurations you have set. You can also run git config --global user.name or git config --global user.email individually to check just those values.

What if I do not have Git installed yet?

You will need to install Git before you can run these commands. read it from git-scm.com for Windows, Mac, or Linux. Once installed, open a new terminal window and the commands above will work.