Before you start recording changes to your projects with Git, you need to perform a simple, one-time setup: telling Git who you are. Every time you save a snapshot of your project (a "commit," as we'll soon learn), Git includes your name and email address as part of that saved information. This is essential for tracking history and collaborating with others, as it clearly identifies the author of each change.
Think of it like signing your name to your work. When you look back at the project's history or work with teammates, it's important to know who made specific modifications.
Fortunately, configuring this identity information is straightforward using the git config
command. You typically only need to do this once per computer.
First, let's tell Git your name. Open your terminal or command prompt (the same one you used for installation if you followed the previous steps). Type the following command, replacing "Your Name"
with your actual name:
git config --global user.name "Your Name"
Press Enter. If the command runs successfully, you won't see any confirmation message, which is typical for many command-line tools.
Next, configure your email address. Use the email address you want associated with your code contributions. This is often the same email you use for Git hosting platforms like GitHub or GitLab. Replace "youremail@example.com"
with your email:
git config --global user.email "youremail@example.com"
Again, press Enter.
--global
FlagYou might notice the --global
option in both commands. This tells Git to apply this configuration setting to all Git repositories you work with under your current user account on this computer. It saves your name and email in a global configuration file. This is usually what you want.
If you need to use a different name or email for a specific project (for instance, using your work email for company projects and your personal email for personal projects), you can omit the --global
flag. To do this, navigate into the specific project's directory using the cd
command in your terminal, and then run the git config
commands without --global
:
# Inside your specific project directory
git config user.name "Your Work Name"
git config user.email "work.email@company.com"
Settings configured without --global
(local settings) override the global settings for that particular repository only.
How can you be sure your settings were saved correctly? You can ask Git to show you its configuration. To see all your global settings, including the name and email you just set, use:
git config --list --global
Alternatively, you can check specific settings:
git config user.name
# Expected output: Your Name
git config user.email
# Expected output: youremail@example.com
If you don't see the expected output, or if you made a typo, simply rerun the appropriate git config --global
command with the correct information. It will overwrite the previous value.
With your identity configured, Git now knows who you are. You're ready to start using Git to manage your projects, beginning with creating your first repository and making your initial commit, which we'll cover in the next chapter.
© 2025 ApX Machine Learning