Introduction to Git

Git keeps a history of every change you make to a project, so you can see what changed, when, and why — and get back to any earlier point if something breaks.

Why version control at all

Imagine editing a document by constantly duplicating it — essay.doc, essay_final.doc, essay_final_v2.doc, essay_ACTUALLY_final.doc. It works for a while, but it falls apart fast: you can't tell what changed between versions, you can't merge two people's edits together, and cleaning up old copies means losing history you might need later. Git solves this properly. Instead of full copies, it stores a series of snapshots ("commits"), each one recording exactly what changed, who changed it, and when — without you ever needing to rename a single file.

This matters even if you're the only person touching the code. The moment you can say "this bug wasn't here three days ago, let me see what changed," version control has already paid for itself.

Installing Git

Git is free and runs on Windows, macOS, and Linux. On macOS and most Linux distributions it's often already installed; you can check with:

$ terminal
git --version
Terminal output
git version 2.43.0

If that command isn't found, install it from git-scm.com — the installer for your operating system will get you the git command in your terminal.

Telling Git who you are

Every commit you make is stamped with a name and an email address, so a team (or future you) can tell who made which change. You only need to set this once per machine:

$ terminal
git config --global user.name "Ava Chen"
git config --global user.email "ava@example.com"

The --global flag applies this to every repository on your machine. You can override it for a single project by running the same commands without --global from inside that project's folder.

Note: Git isn't GitHub. Git is the version-control tool that runs on your computer; GitHub (and alternatives like GitLab or Bitbucket) is a website that hosts Git repositories online so people can share and collaborate on them. You'll meet that side of things in the Working with Remotes lesson.