So far you've been writing HTML and CSS files on your computer. You save a file, refresh the browser, and see your changes. That works great — until it doesn't.
What happens when you change something and your page breaks? What if you want to try a bold new layout but you're scared you'll ruin what already works? What if you're working with a teammate and you both edit the same file at the same time?
This is where Git comes in.
What Is Git?
Git is a version control system. Think of it like a time machine for your code. Every time you save a meaningful snapshot of your project, Git remembers exactly what your files looked like at that moment. You can go back, compare versions, or undo mistakes.
Git is not the same thing as GitHub. Git is the tool on your computer. GitHub (and GitLab, Bitbucket, etc.) are websites that store your Git projects online so you can back them up and collaborate with others. We'll get to remote hosting later — for now, everything happens locally on your machine.
Why Web Developers Use Git
- Safety net — Break something? Roll back to when it worked.
- History — See who changed what and when (even if that "who" is just future-you).
- Experimentation — Try ideas on a branch without touching your main code.
- Collaboration — Multiple people can work on the same project without emailing zip files back and forth.
The Core Idea
At its heart, Git tracks changes to files inside a repository (often shortened to "repo"). A repo is just a project folder that Git is watching.
You work on files normally in your editor. When you're happy with a set of changes, you tell Git to record them as a commit — a saved snapshot with a message describing what you did.
Before we can commit, we need to stage changes with git add. That's the command we'll build toward in this module. But first, let's get Git installed and create our first repository.