Git & GitHub・Getting to know Git

What is Git, and how is it different from GitHub?

Git is the tool that saves you from ever naming a file "final_v2_really-final.html" again. Here's what it records, how you get back to an earlier state, and how it differs from GitHub.

Have you ever copied index_backup.html before making a big change? Git does that copying for you — automatically, cleanly, as many times as you like. This lesson covers what Git actually records, and clears up the confusion between Git and GitHub.

Where backup-by-filename breaks down

Manual backups turn into this very quickly:

index.html
index_backup.html
index_backup2.html
index_final.html
index_final_really-final.html

A few days later, nobody knows which one is current or what changed between them. And even a one-character edit means another full copy of the file.

Git solves this differently: it records the history of changes without multiplying your files.

Git records “the state at that moment” under a name

Recording in Git is called a commit. When you commit, the contents of your folder at that moment are recorded, along with a short message about what you did.

commit 3  ← now   "Add the thank-you message to the form"
commit 2          "Add the favorites list"
commit 1          "Build the page skeleton"

What this buys you:

  • You can go back — “I changed it and it broke” is solved by rewinding one commit
  • You can remember what you did — the messages stay in the history, which future you will thank you for
  • You can make big changes calmly — with a record behind you, ambitious rewrites stop being scary

Git and GitHub are two different things

This is the first thing that trips people up. Similar names, different jobs.

GitGitHub
What it isA tool that records changes (software)A place that stores those records (web service)
Where it runsOn your own computerOn the internet
What you lose without itYour historyEverything, if your computer dies
CostFreeFree for personal use

Git alone keeps your history. Putting it on GitHub gives you a backup, a way to share, and the ability to publish the site directly.

The GitHub home page, with a large headline in the center and a field for entering your email to sign up
The GitHub home page. Developers all over the world publish their code here.

GitHub

Only three words to learn at first

Git has a lot of vocabulary, but you only need these to begin.

WordMeaning
RepositoryThe folder whose history is being recorded — the unit you decided to manage with Git
CommitRecording the current state, or one such record
PushSending your local records to GitHub

With these three, the commands in the coming lessons will make sense.

Summary of this lesson

  1. Git is a tool that records changes so you can return to any earlier state. It runs on your machine
  2. The unit of recording is a commit — the whole state at that moment, with a message attached
  3. GitHub is the web service that stores those records, giving you backup, sharing, and publishing

FAQ

What is Git?
A tool that records changes to your files so you can return to an earlier state at any time. It's called a version control system, and it runs on your own computer.
What is the difference between Git and GitHub?
Git records changes on your machine; GitHub is a service that stores those records online so you can back them up, share them, and publish them. Git is the tool, GitHub is the place.
Do I need Git for a site I build on my own?
It isn't required, but it helps even solo. You can roll back when a change breaks things, and GitHub Pages lets you publish your site for free.