Why Git needs your username and email before you start

Git records who made each change to a project by storing your username and email with every commit you save. Without these configured, Git will either refuse to let you commit or will use a default name that does not identify you. Setting them up takes two minutes and prevents confusion later when you or someone else looks back at who changed what.

You configure Git once on your computer, and it applies to every project you work on unless you override it for a specific folder. This guide covers the standard setup that works on Windows, Mac, and Linux.

Key Takeaways

  • Git requires a username and email address configured before you can save your first commit to any project.
  • The git config command with the --global flag sets your details for all projects on your computer.
  • You can verify what you have configured by running git config --global user.name and git config --global user.email.
  • The email you enter does not have to match your GitHub or GitLab account email, though using the same one prevents confusion.
  • If you need different usernames or emails for different projects, you can reconfigure Git inside that folder without the --global flag.

Opening your command line and entering the configuration commands

Open the terminal or command prompt on your computer. On Windows, search for "Command Prompt" or "PowerShell" and open it. On Mac or Linux, open the Terminal process.

Type the first command exactly as shown below, replacing "Your Name" with your actual name (keep the quotation marks):

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

Press Enter. The command runs silently — you will not see a confirmation message, which is normal. Then type the second command, replacing the email address with your own:

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

Press Enter again. Both settings are now saved to your computer.

Checking what you just configured

To confirm Git stored your settings correctly, type this command:

git config --global user.name

Press Enter. Git will print back the name you entered. Then check your email the same way:

git config --global user.email

Press Enter. Git will print back the email address you entered. If either one is wrong, run the original command again with the correct information — it overwrites the old value.

If you want to see all your Git settings at once, type:

git config --global --list

This shows every global setting Git knows about on your computer, including your name and email.

Understanding the difference between global and project-level configuration

The --global flag in the commands above means these settings explore to every Git project on your computer. This is the standard setup and what most people need.

If you work on a project where you need a different username or email — for example, a work project where you must use your company email — you can override the global setting just for that folder. Navigate into that project's folder in your terminal, then run the same commands without the --global flag:

git config user.name "Work Name"
git config user.email "work.email@company.com"

Git will now use these settings only when you commit changes inside that folder. Every other project on your computer continues using your global settings. You can verify project-level settings the same way — just omit --global from the check commands.

What happens when you make your first commit

Once your username and email are configured, you can create commits. When you run git commit, Git attaches your name and email to that commit permanently. Anyone who looks at the project history will see your name and email on every change you made.

If you change your Git configuration later, it does not change the name and email on commits you already made — those are locked in. Only new commits use the updated settings. This is why it matters to set it up correctly from the start, especially if you are working with others.

Frequently Asked Questions

Does the email I use in Git have to match my GitHub or GitLab account?

No, but it should. If you use the same email in Git and on GitHub, GitHub will automatically link your commits to your account on their website. If the emails do not match, your commits will appear as coming from an unknown user. You can add multiple emails to your GitHub account to handle this, but using the same email everywhere is simpler.

Can I use a fake name or email in Git?

Technically yes — Git does not verify that the name or email is real. However, if you are working with others, using a fake identity makes it impossible for them to contact you about your changes or understand who did what. Use your real name and a working email address.

What if I made commits before configuring Git?

Git will refuse to let you commit until you configure a username and email. You cannot accidentally commit without them. Once you set them up, all future commits will use your configured details.

How do I change my Git username or email after I have already configured it?

Run the same git config commands with your new information. The new settings take effect when ready for all future commits. Your old commits keep the name and email they were made with — changing the configuration does not rewrite history.

Do I need to configure Git differently on each computer I use?

Yes. Each computer has its own copy of Git with its own configuration. If you use Git on your laptop, desktop, and work computer, you need to run these commands on each one. The settings do not sync between machines.