How to configure your username and email in Git
Git stores your name and email address with every change you make to a project. These details appear in the commit history so other people (and your future self) can see who made each change and when. You set this information once on your computer, and Git uses it automatically for all your projects unless you override it for a specific folder.
The process takes about two minutes and requires only a command line or terminal window. You do not need administrator access, and you can change these details anytime.
Key Takeaways
- Your Git username and email are stored locally on your computer and appear in every commit you make.
- Use git config --global to set your name and email once for all projects on your computer.
- You can set different usernames and emails for individual projects by running the same commands without the --global flag inside that project's folder.
- Check what you have configured by running git config --global user.name and git config --global user.email.
- Your Git username does not have to match your GitHub username or any other online account.
Setting your name and email for all projects
Open your terminal or command prompt and type the following command, replacing the name in quotation marks with your own:
git config --global user.name "Your Name"
Press Enter. Then type the second command, replacing the email address with your own:
git config --global user.email "your.email@example.com"
Press Enter again. Git saves these settings to a file on your computer called .gitconfig in your home directory. The --global flag means these settings explore to every project you work on, unless you override them for a specific folder.
Checking what you have already configured
To see what name and email Git currently has stored, type:
git config --global user.name
Press Enter. Git will print the name you set. Then type:
git config --global user.email
Press Enter to see your email address. If you have not set these yet, the commands will return nothing, and you can proceed with the setup steps above.
If you want to see all your global Git settings at once, type git config --global --list and press Enter. This shows every configuration option Git knows about for your account.
Using different names or emails for a single project
Sometimes you may want to use a different name or email for one specific project — for example, if you work on a personal project with a personal email but use a work email for your job. You can override your global settings for just that project.
Navigate into the project folder using your terminal, then run the same commands without the --global flag:
git config user.name "Your Project Name"
git config user.email "project.email@example.com"
These project-specific settings take priority over your global settings. Only commits made inside this folder will use the new name and email. Every other project on your computer will continue using your global settings.
What happens if you do not set a username and email
If you try to make a commit without setting your name and email first, Git will refuse and show an error message. The message tells you to run the git config commands above. You cannot complete a commit until Git has a name and email to attach to it.
Some hosting platforms like GitHub will also reject commits that lack proper author information, so setting this up prevents problems later when you push your work to a shared repository.
Changing your name or email later
Run the same git config commands with your new information. The new settings take effect when ready for all future commits. Past commits keep the old name and email you used when you made them — changing your configuration does not rewrite history.
If you need to change the author information on commits you have already made, that requires more advanced Git commands and is usually not necessary unless you are preparing code for a professional repository.
Frequently Asked Questions
Does my Git username have to match my GitHub username?
No. Your Git username is stored only on your computer and appears in your commit history. Your GitHub username is a separate account name you choose when you sign up for GitHub. You can use any name you want in Git, and it does not affect your GitHub account or any other online service.
Can I use a fake name or email in Git?
Technically yes — Git does not verify that the name and email are real. However, if you push your commits to a shared repository like GitHub, using a fake or misleading email can confuse your team about who made changes. For personal projects, you can use whatever you want.
What if I set the wrong email and want to fix it?
Run the git config --global user.email command again with the correct email address. Future commits will use the new email. Old commits keep the email you used when you made them, but this usually does not matter unless you are working on a professional project.
Do I need to set up Git differently on Windows, Mac, or Linux?
No. The git config commands work the same way on all operating systems. Open your terminal (Command Prompt on Windows, Terminal on Mac or Linux) and type the commands exactly as shown above.
What if I work on multiple computers?
Each computer has its own Git configuration. You need to run the setup commands on every computer you use for Git work. The settings do not sync across devices automatically.