Why Git needs your name and email
Every time you save work in Git, the system records who made that change and when. Git uses your name and email to create that record — it's how your teammates see who wrote each piece of code, and how you can find your own changes months later. Without setting this up, Git will either refuse to save your work or use a default name that doesn't identify you.
The name and email you configure are stored locally on your computer. They're not connected to your GitHub account or any online service — they're just the identity Git uses when you're working on your machine. You only need to set them once, though you can change them anytime.
Key Takeaways
- Git requires a name and email before you can save changes; these are stored on your computer, not online.
- Use the git config command with the --global flag to set your identity once for all projects on your machine.
- The name you enter should be your actual name or the name you want associated with your work; the email can be any address you control.
- You can verify what you've set by running git config --global user.name and git config --global user.email.
- If you need a different name or email for a specific project, you can set project-level configuration without the --global flag.
Opening the command line on your computer
Git commands run through your computer's command line — the text-based interface where you type instructions. On Windows, this is Command Prompt or PowerShell. On Mac or Linux, it's Terminal. Open whichever one your system uses.
If you're not sure how to open it, search your computer for "Command Prompt" (Windows) or "Terminal" (Mac/Linux) and click the result. You'll see a blank window with a blinking cursor where you can type.
Entering your name in Git
Type this command exactly as shown, replacing "Your Name" with your actual name:
git config --global user.name "Your Name"
Press Enter. The command will run silently — you won't see a confirmation message, and that's normal. Git has stored your name. Use your real name or the name you want associated with your work. If you work on a team, use the name your teammates will recognize.
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 Dupont" both work correctly.
Entering your email in Git
Type this command next, replacing "your.email@example.com" with an email address you control:
git config --global user.email "your.email@example.com"
Press Enter. Again, no confirmation message appears — that's expected. Git has stored your email. The email doesn't have to match any online account; it's just the address Git records with your changes. You can use a work email, personal email, or any address you own.
If you later use GitHub or another online service, you can link your Git configuration to that account, but you don't need to do that now. The email you enter here is purely local.
Checking what you've set
To confirm Git has your information stored correctly, type this command:
git config --global user.name
Press Enter. Git will print back the name you entered. Then type:
git config --global user.email
Press Enter again. Git will print back your email. If either one is wrong or missing, run the setup commands again with the correct information — the new entry will overwrite the old one.
Setting different names or emails for specific projects
The --global flag tells Git to use these settings for every project on your computer. Sometimes you might want different settings for a single project — for example, using your work email for a work project and your personal email for a hobby project.
Navigate to that project's folder in your command line, then run the same commands without the --global flag:
git config user.name "Your Work Name"
git config user.email "work@company.com"
These project-level settings override your global settings only for that folder. When you work in other projects, Git uses your global name and email instead. This is useful if you juggle multiple identities or organizations, but most people only need the global setup.
What happens next
Once you've set your name and email, Git is ready to record your changes. The next time you save work in a project — whether you're creating a new repository or working in an existing one — Git will attach your name and email to that save. Your teammates will see your identity, and you'll be able to track your own contributions.
If you ever change computers or reinstall Git, you'll need to run these configuration commands again on the new machine. The settings don't transfer automatically because they're stored locally on each computer.
Frequently Asked Questions
Can I use a fake name or email in Git?
Technically yes, but don't. Your name and email are how your team identifies your work and contacts you about changes you've made. Using false information creates confusion and breaks the trust that version control depends on. Use your real name and a real email address you check.
What if I make a mistake when setting my name or email?
Run the configuration command again with the correct information. The new entry overwrites the old one when ready. You can verify the change by running git config --global user.name or git config --global user.email to see what's currently stored.
Do I need to set my name and email for each project?
No. The --global flag sets them once for your entire computer. Every project you work on will use these settings unless you specifically override them with project-level configuration. Most people only need to set this once.
Can I change my name or email later?
Yes. Run the configuration commands again with your new information, and Git will use the new details for all future changes. Past changes will still show your old name and email — Git doesn't rewrite history. If you need to update old commits, that's a more advanced task.
What if I don't set a name and email before saving changes?
Git will refuse to save your work and show an error message telling you to configure user.name and user.email. You won't lose any work — Git straightforward won't let you proceed until you've set these details. Run the configuration commands, then try saving again.