Lesson 2 - Installing and Configuring Git

Welcome to Installing and Configuring Git

In the last lesson you learned what version control is and why Git is worth knowing. Now you’ll make it real on your own computer. This lesson does two things: it gets Git installed and confirmed working on whatever operating system you use, and it sets up your identity — the name and email Git stamps onto every snapshot you create. That second part matters more than it sounds: a commit with no author is a commit nobody can take credit for, and once you connect to GitHub later, the email you set here is what links your work back to you.

Everything here is a one-time setup. Do it once and Git is ready for every project you ever start.

By the end of this lesson, you will be able to:

  • Install Git on macOS, Windows, or Linux
  • Confirm the install worked with git --version
  • Set your author identity with git config --global user.name and user.email
  • Choose sensible defaults and view your configuration with git config

Let’s begin.


Installing Git on Your Computer

Git runs on every major operating system. Pick the section that matches yours — you only need one.

macOS

The simplest route on a Mac is Homebrew, the popular package manager. If you already have Homebrew, install Git with:

$ brew install git

If you don’t use Homebrew, macOS can install Git for you through the Xcode Command Line Tools. Just type a Git command, and macOS will offer to download the tools automatically:

$ xcode-select --install

Either path gives you a working git command in your terminal.

Windows

On Windows, download the installer from the official site, git-scm.com. This is Git for Windows, and it includes Git Bash — a terminal that gives you the same Git commands (and a Unix-style shell) that macOS and Linux users have. Run the installer and accept the defaults; the defaults are sensible for beginners.

When you’re done, open Git Bash from the Start menu and run your Git commands there. Throughout this course, when you see a $ prompt, that’s the kind of terminal we mean.

Linux

Most Linux distributions install Git through their package manager. On Debian or Ubuntu:

$ sudo apt install git

On Fedora, Red Hat, or similar:

$ sudo dnf install git

You may be asked for your password, since installing software needs administrator rights.


Confirming the Install

Whichever method you used, confirm Git is installed by asking it for its version:

$ git --version
git version 2.50.0

If you see a line like git version followed by a number, Git is installed and on your path — you’re ready to configure it. Your exact version number may differ from 2.50.0 above, and that’s completely fine; any recent version works for this course. If instead you see an error like command not found, the install didn’t complete or your terminal needs to be closed and reopened so it picks up the new command.


Setting Your Identity

Before you make your first commit, Git needs to know who you are. Every commit records an author name and email, and Git refuses to guess them. You set them once with git config:

$ git config --global user.name "Ada Skye"
$ git config --global user.email "[email protected]"

These two commands print nothing when they succeed — silence means it worked. We’ll use Ada Skye / [email protected] as the running example author throughout this course, but you should use your own name and the email address you plan to use for GitHub. Using that same email matters: when you start pushing work to GitHub, it’s how your commits get linked back to your account and shown under your profile.

The --global flag is the important part here. It writes these settings to a per-user configuration file (~/.gitconfig), so they apply to every repository you work in on this computer. You set your identity once and never think about it again.

Global config is per-user, not per-project

git config --global saves settings to a single file in your home folder (~/.gitconfig) that applies to all your repositories. If you ever need a different identity for one specific project — say a work repo with a work email — you can run git config inside that repository without --global, and that per-repo setting overrides the global one just for that project. Also: use the same email as your GitHub account so your commits link to you once you start pushing to GitHub.


Sensible Defaults and Viewing Your Config

Beyond your identity, one default is worth setting now. When Git creates a new repository, it names the starting branch — historically master, but the modern convention (and what GitHub uses) is main. Make Git use main from the start:

$ git config --global init.defaultBranch main

You can also tell Git which text editor to open when it needs you to type something (like a longer commit message). For example, to use VS Code:

$ git config --global core.editor "code --wait"

This one is optional — if you skip it, Git uses your system’s default editor.

To see everything you’ve configured, list your global settings:

$ git config --global --list
user.name=Ada Skye
user.email=[email protected]
init.defaultbranch=main

Each line is a key=value pair. Notice that Git stores the key as init.defaultbranch (lowercased) even though you typed it with a capital B — Git treats the key name case-insensitively, so both work.

If you just want to check a single setting rather than the whole list, name the key directly:

$ git config user.name
Ada Skye

That’s the full setup. Git is installed, it knows who you are, and it’s set to use sensible defaults — ready for your first repository in the next lesson.


Practice Exercises

Exercise 1: Confirm your install

Open your terminal (Git Bash on Windows) and run the command that prints Git’s version. What output tells you Git is correctly installed?

Hint

Run git --version. A line beginning with git version followed by a number (for example, git version 2.50.0) means Git is installed and available. Your number may differ from the example — any recent version is fine. If you see command not found, the install didn’t finish or you need to reopen your terminal.

Exercise 2: Set your own identity

Set your author name and email using git config --global, then read back the name you set with a single command. Use your own name and the email you’ll use for GitHub.

Hint

Run git config --global user.name "Your Name" and git config --global user.email "[email protected]" (these print nothing when they succeed). Then read one key back with git config user.name, which prints just that value.

Exercise 3: Inspect everything at once

After setting your identity and the default branch name, view your complete global configuration. What does --global mean in that command, and where are these settings stored?

Hint

Run git config --global --list to see every key=value pair, including user.name, user.email, and init.defaultbranch. The --global flag means the settings are per-user — saved in ~/.gitconfig in your home folder — so they apply to all your repositories, not just one.


Summary

You installed Git for your operating system — Homebrew (brew install git) or the Xcode Command Line Tools on macOS, Git for Windows / Git Bash from git-scm.com on Windows, and sudo apt install git or sudo dnf install git on Linux — and confirmed it with git --version. Then you set up Git as a one-time task: your identity (git config --global user.name and user.email) so every commit is attributed to you, and a sensible default (git config --global init.defaultBranch main) so new repositories start on main. You also learned to view your settings with git config --global --list and read a single key with git config user.name. With Git installed and knowing who you are, you’re ready to create your first repository.

Key Concepts

  • git --version — confirms Git is installed and shows which version you have.
  • git config --global user.name / user.email — set the author identity stamped on every commit; use the email tied to your GitHub account.
  • init.defaultBranch main — makes new repositories start on a branch named main.
  • --global vs per-repo — global settings live in ~/.gitconfig and apply to all your repos; running git config without --global inside a repo overrides them just for that project.
  • Viewing configgit config --global --list shows all settings; git config <key> reads one.

Why This Matters

Configuring Git is a five-minute task you’ll never repeat, but it shapes everything that follows. Without an identity, Git won’t let you commit; with the wrong email, your work won’t connect to your GitHub profile later. Setting your name, email, and default branch now means every snapshot you create from here on is correctly labeled and ready to share — so you can focus on learning Git itself rather than fixing attribution after the fact.


Next Steps

Continue to Lesson 3 - Your First Repository

Create a Git repository, make your first commit, and see the snapshot model from Lesson 1 in action.

Back to Module Overview

Return to the Version Control Foundations module overview


Continue Building Your Skills

Git is now installed, verified, and configured with your identity and a sensible default branch. That setup is done for good. In the next lesson you’ll put it to work — turning a plain folder into a Git repository and recording your very first commit.