Getting Started
20 minutes
linux
macos
windows

Installing Git

Learn what Git is, why you need it, and how to install it on any operating system.

What you'll accomplish

Have Git installed and configured with your name and email.

Prerequisites

  • Completed "What is a Terminal?" lesson
  • A computer (Windows, Mac, or Linux)

What is Git?

Git is a version control system - software that tracks changes to your files over time.

Imagine you're playing a video game. Before fighting a tough boss, you save your game. If you lose, you can reload and try again.

Git does the same thing for your code:

  • Save your progress at any point (called a "commit")
  • Go back to any previous save if something breaks
  • See exactly what changed between saves
  • Work with others without overwriting each other's work

Without Git, if you break your code, you might lose hours of work. With Git, you just go back to your last save.

Why Do You Need Git?

Even if you're working alone, Git is essential:

Without GitWith Git
"I'll just copy this folder to folder_backup_v2_final_FINAL"Clean history of every change
"What did I change that broke this?"See exactly what changed and when
"I accidentally deleted that important code"Recover anything you've committed
Can't experiment freelyTry anything, revert if it fails

AI coding assistants like Claude Code make many changes quickly. Git is critical because:

  1. Rollback capability: If the AI makes a mistake, you can undo it instantly
  2. Change review: You can see exactly what the AI modified before accepting changes
  3. Experimentation: Try different AI suggestions without fear
  4. Collaboration: Share your AI-assisted code with others properly

Most AI coding tools won't even run without Git installed.

Installing Git

Configuring Git

After installing, you need to tell Git who you are. This information is attached to every change you save.

When you save changes (commit), Git records:

  • What changed
  • When it changed
  • Who made the change (your name + email)

This is important when working with others so everyone knows who did what. The email should match your GitHub account if you plan to use one.

Note: This email can be seen by others in public projects. If you want privacy, GitHub offers a "no-reply" email address in your settings.

Verify your configuration:

bash
git config --list

You should see your name and email in the output.

Basic Git Concepts

Before moving on, let's understand a few key terms you'll encounter:

TermWhat it means
Repository (repo)A folder that Git is tracking. Contains your project and its history.
CommitA saved snapshot of your project. Like a save point in a game.
BranchA parallel version of your code. Used for experimenting safely.
CloneDownloading a copy of someone else's repository.
PushUploading your commits to a remote server (like GitHub).
PullDownloading new commits from a remote server.

Imagine your project is a tree:

  • The repository is the whole tree
  • The main branch is the trunk
  • Branches are... branches! Places to try new things
  • Commits are like growth rings - they record the tree's history
  • GitHub is like a tree nursery where you can share and backup your tree

You'll learn all of these as you use Git. For now, just knowing these words exist is enough!

Test Your Installation

Let's make sure everything works by creating a test repository:

  • mkdir ~/git-test - Created a new folder called "git-test" in your home directory
  • cd ~/git-test - Moved into that folder
  • git init - Told Git to start tracking this folder (created a hidden .git folder inside)
  • git status - Asked Git "what's happening in this repository?"
  • rm -rf ~/git-test - Deleted the test folder (we were just testing!)

Common Issues

Frequently Asked Questions

Windows: Open a NEW PowerShell window. The PATH changes from installation only apply to new terminals.

All systems: Make sure the installation completed successfully. Try reinstalling if needed.

This usually happens with GitHub/GitLab. You can set up SSH keys or a credential helper to avoid this. We'll cover this when you connect to GitHub.

Older versions of Git used "master" as the default branch name. Newer versions use "main". Both work the same way - it's just a name.

To change the default for new repositories:

bash
git config --global init.defaultBranch main

Linux/Mac: You may need to add sudo before the install command.

Windows: Try running PowerShell as Administrator (right-click → "Run as administrator").

Verify Your Understanding

You've completed this lesson if you can:

0/4

Next: Learn how to install Node.js, the JavaScript runtime that powers most modern web development.