Install Git and Configure Identity

Learn to install Git on Windows, macOS, or Linux and set your user name and email for commits. Step-by-step instructions, troubleshooting tips, and what to learn next.

Focus: install git and configure your identity

Sponsored

You’re ready to start using Git, but the moment you type git commit, a stubborn error halts everything: “Please tell me who you are.” That’s because Git is a distributed version control system, and every change you make is stamped with an identity—your name and email. Without configuring that identity, Git refuses to record your work. This lesson removes that first roadblock: you’ll install Git on your operating system and configure your user name and email, so your commits are correctly attributed and your Git journey can begin without friction.

The problem this lesson solves

Imagine you’ve just written a critical piece of code. You run git add . and git commit -m "Initial commit". Instead of a success message, Git spits out an error that stops you cold:

$ git commit -m "Initial commit"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

This happens because Git, unlike centralized version control systems, has no central server to ask who you are—it trusts you to declare it. If you skip config, Git can’t attribute the commit to you, and collaboration (and accountability) breaks down.

Why this matters right now

  • Every commit is permanent (until you start rewriting history, which you’ll learn later). A misconfigured email can haunt you for years.
  • Tools like GitHub use your Git identity to link commits to your account. Wrong email = commits not credited to you.
  • Team workflows rely on accurate authorship for code reviews, blame, and release notes.

By the end of this lesson, you’ll be able to install Git and configure your identity—the essential first step for all future Git work.

Core concept / mental model

Think of Git as a time-traveling archive for your code. Every commit is a snapshot with a label: who made it, when, and what changed. The “who” is your identity—your name and email. Git stores this in a config file, similar to a preferences file for an app.

Git’s configuration levels

Git reads settings from three levels, in order (later overrides earlier):

  1. System: applies to every user on the machine (/etc/gitconfig).
  2. Global: applies to all your repositories (~/.gitconfig on Linux/macOS, C:\Users\<you>\.gitconfig on Windows).
  3. Local: specific to one repository (.git/config inside the repo).

Your identity should normally be set at the global level—it’s your default for everything. Use local only if you need a different identity for a specific project (e.g., work vs. personal).

Pro tip: Use git config --list --show-origin to see where each setting comes from and in what order.

The core commands

  • git config: the all-in-one tool to set or get config variables.
  • git config --global user.name "Your Name": sets your name.
  • git config --global user.email "you@example.com": sets your email.
  • git config --list: verifies current settings.

Once set, Git uses these values on every commit you make—until you change them.

How it works step by step

Step 1: Install Git

If Git isn’t already installed, you need it. Here’s how to check and install on each OS.

Check if Git is installed

git --version

If you see something like git version 2.39.1, you’re ready. If not, install it.

Installing on Windows

  1. Download the installer from git-scm.com.
  2. Run the .exe file. Accept the defaults—they’re sensible for beginners (e.g., Git Bash, checkout as-is, commit as-is).
  3. Once done, open Git Bash (not the default Command Prompt) to work with Git commands.

Installing on macOS

  • Option A: Install Xcode Command Line Tools: xcode-select --install (this installs Git too).
  • Option B: Install via Homebrew: brew install git.

Installing on Linux (Ubuntu/Debian)

sudo apt update
sudo apt install git

For other distributions (Fedora, Arch), use their package managers (dnf, pacman). Identify your OS so you pick the right method.

Step 2: Configure your identity

Once Git is installed, set your name and email. Open your terminal (Git Bash on Windows, Terminal on macOS, shell on Linux) and run:

git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"

Replace with your real name and email. Use the email you plan to use with GitHub or other hosting services.

Step 3: Verify your configuration

git config --global --list

Expected output (values will differ):

user.name=Ada Lovelace
user.email=ada@example.com

Or check individual values:

git config --global user.name
git config --global user.email

Step 4: Make your first commit

Initialize a repository and test that your identity works:

mkdir myproject
cd myproject
git init
echo "Hello Git" > README.md
git add README.md
git commit -m "Initial commit"

You should see output including your name and email, confirming proper attribution.

Hands-on walkthrough

Let’s put it all together with a complete, runnable exercise.

Exercise: Install and configure

# 1. Check Git version (if not installed, install per your OS)
git --version

# 2. Set your identity globally
git config --global user.name "Ada Lovelace"
git config --global user.email "ada@example.com"

# 3. Verify
git config --global --list

# 4. Initialize a test repo and commit
git init test-repo
cd test-repo
echo "Learning Git" > README.md
git add .
git commit -m "First commit from setup lesson"

# 5. Show the commit author
git log --oneline --format="%h %an <%ae>"

Expected output (your name/email will appear):

1a2b3c4 Ada Lovelace <ada@example.com>

This confirms your identity is attached to the commit.

If you see an error

  • Git not recognized: The install didn’t add Git to your PATH. On Windows, reopen Git Bash; on macOS/Linux, log out/in or restart your terminal.
  • Permission errors: Make sure you’re not using sudo with git config --global on Linux/macOS (global config is per-user).

Compare options / when to choose what

You can configure identity at various levels, and you have choices for the email itself. Here’s how to decide.

Configuration level comparison

Level Scope Use case Command example
--system All users on machine Shared CI environments git config --system user.name "CI Bot"
--global All your repos Default identity git config --global user.name "Ada"
--local Current repo only Work vs. personal per project git config --local user.name "Ada Work"

When to choose what: - Global for day‒to‒day; set once, use everywhere. - Local to override for a specific repo (e.g., a freelance project). - System rarely—only for shared machines.

Email options

Option Pros Cons
Personal email Simple, direct Exposes your email publicly if repo is public
GitHub noreply email Privacy, shields real email Must look it up in GitHub settings
Work email Matches corporate identity Mixes personal projects

When to choose: Most beginners pick their primary email. For privacy, use GitHub’s ID+username@users.noreply.github.com (find it under Settings → Emails).

Troubleshooting & edge cases

You’ve installed and configured, but things can still go wrong. Here are the common pitfalls and fixes.

“Please tell me who you are” after configuring

You set user.name and user.email, but Git still complains. Why? - Local override: A repo may have a local config that overrides global. Check with git config user.name inside the repo. Fix: git config --local --unset user.name or set the correct local value. - Typo in config command: Verify with git config --list. Re-run the global commands. - Environment variables: If GIT_AUTHOR_NAME or GIT_COMMITTER_EMAIL are set (e.g., in CI), they take priority. Unset them or check your shell profile.

Fix: Run git config --list --show-origin to see which file is providing the offending value.

Wrong email in past commits

If you’ve already committed with the wrong email, don’t panic. You can change the author of the last commit (amending) — full history rewriting is advanced. For the last commit, use git commit --amend --reset-author. For multiple commits, that’s a rebase topic for later.

Pro tip: Always double-check your configuration before making a series of commits—fixing a mistake across many commits is painful.

Git not found after installation

  • Windows: Reopen Git Bash or restart your terminal to reload PATH.
  • macOS: If using Homebrew, ensure /usr/local/bin (Intel) or /opt/homebrew/bin (Apple Silicon) is in your PATH.
  • Linux: Install via your package manager, then run hash -r to clear the command cache.

What you learned & what's next

You now know the essential first step in Git: installing Git and configuring your identity. You can:

  • Install Git on your specific OS.
  • Set your user.name and user.email globally.
  • Verify your configuration.
  • Troubleshoot common identity errors.
  • Create a commit that’s correctly attributed to you.

This foundation is crucial because every subsequent Git lesson—staging changes, creating branches, pushing to a remote—depends on clean identity configuration. Without it, your actions remain anonymous and workflows break.

Now you’re ready to move on to the next lesson in the Git Tutorial: Staging and Committing Changes. You’ll learn how Git’s staging area works and how to craft meaningful commits. Your identity is set; your journey has begun.

Practice recap

In a clean directory, initialize a repository, make three commits, and then inspect git log --format='%an <%ae>' to confirm each commit shows your configured identity. Next, override your identity locally in the same repo and make another commit, then run git log again to see the change. This reinforces how config precedence works.

Common mistakes

  • Forgetting to configure identity before the first commit, causing the 'Please tell me who you are' error.
  • Setting identity only locally in one repo, then wondering why commits in other repos show the wrong author.
  • Using an email that doesn't match the one on GitHub, so commits aren't linked to the account.
  • Editing .gitconfig manually with a text editor and introducing syntax errors—prefer git config commands.
  • Assuming git config --global is the only place—overlooked --local overrides.

Variations

  1. Use a Git GUI (GitHub Desktop, Sourcetree) that sets up identity through the interface, but manual CLI config is more flexible.
  2. Centralized systems like Subversion ask for credentials per commit, whereas Git uses a local config—understanding this shift prevents confusion.
  3. The GIT_AUTHOR_NAME and GIT_COMMITTER_EMAIL environment variables let you set identity transiently for scripts or CI pipelines.

Real-world use cases

  • A new developer installs Git on a corporate laptop and sets their work email via git config --global so every commit in any repo is attributed to them.
  • A freelancer keeps two identities: global personal email, then overrides with a local repo config to use a client-specific email on that project.
  • A CI/CD pipeline sets environment variables GIT_AUTHOR_NAME and GIT_COMMITTER_EMAIL to make automated commits from the bot account, not the developer's identity.

Key takeaways

  • Git requires an identity before commits; setting user.name and user.email globally solves this for all repos.
  • Config levels (system, global, local) override in order—use global for defaults, local for per-project exceptions.
  • Always verify with git config --list or git config user.name to catch typos and local overrides.
  • An incorrect email can fail to link commits to your GitHub account, so choose it carefully.
  • Troubleshooting identity errors centers on --show-origin and environment variables.
  • Installing Git differs by OS—use package managers (apt, brew, or the official installer) suited to your platform.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.