Find a course

Module 1: Getting Started with Version ControlLesson 1 of 129 min

What Is Version Control?

See the problem version control solves, how Git records snapshots of a project, and how Git, a tool on your computer, differs from GitHub, a hosting service.

Step 1 of 12Learn

final_v2_REAL_use_this_one

Priya is writing her thesis. Her folder contains thesis.docx, thesis_v2.docx, thesis_final.docx, thesis_final_v2.docx and thesis_final_REAL.docx. Her advisor asks what changed between the March draft and today. She has no idea. Worse, she deleted a paragraph three weeks ago that she now wants back, and she's not sure which file still has it.

Now imagine five people editing the same files, emailing copies back and forth. Someone's changes always get lost.

Version control solves this. A version control system records snapshots of your project over time. Each snapshot comes with a note saying who made it, when, and why. With it, you can:

  • See exactly what changed between any two versions, line by line
  • Restore a file, or the whole project, to any earlier state
  • Work on an experiment without risking the version that works
  • Combine work from several people without overwriting each other

Git is by far the most widely used version control system. It's free, it runs on Windows, macOS and Linux, and it's the standard in software development. It works for any text-based project, from code and websites to documentation, data scripts and books written in Markdown.

Step 2 of 12Learn

Snapshots, not copies

Git doesn't save a copy of every file each time. When you commit, Git records a snapshot of what your tracked files look like at that moment. Files that didn't change are stored once and simply referenced again, so a project with thousands of commits stays compact.

Each commit gets a unique ID called a hash, a 40-character string of hexadecimal digits like a1b2c3d4.... In practice you'll usually see the first seven characters, such as a1b2c3d. Git calculates the hash from the contents of the commit, so if anything in the history were altered, the IDs would no longer match. That's part of why people trust Git history.

Commits link to their parent commit, forming a chain from the very first commit to the latest. Reading that chain is like reading a project diary: added login page, fixed typo in pricing table, updated contact email.

Git was created in 2005 by Linus Torvalds to manage the source code of the Linux kernel, a project with thousands of contributors. It had to be fast, work offline and handle huge histories. Those design goals are why it scales just as well to a one-person project.

Step 3 of 12Diagram

A history of snapshots

Each commit is a saved snapshot that points to the one before it. Tap a commit to see what it stores.

A history of snapshotsProcess diagram: Commit 1: first draft → Commit 2: add chapter 2 → Commit 3: fix citations → Commit 4: advisor edits.Commit 1:first draftCommit 2:add chapter2Commit 3:fix citationsCommit 4:advisor edits

Tap a shape with to see more.

Commit 1: first draft

Snapshot of every tracked file, plus author, date and message.

Commit 2: add chapter 2

Only the new chapter is stored again; unchanged files are referenced, not copied.

Commit 3: fix citations

Each commit points back to its parent, so the chain is the history.

Commit 4: advisor edits

You can compare any two snapshots, such as March vs. today.

Step 4 of 12Practice · Choose one

Which of these is NOT something Git helps you do?

Step 5 of 12Compare

Git vs. GitHub

AspectGitGitHub
What it isVersion control softwareA website and service that hosts Git repositories
Where it runsOn your computerIn the cloud, accessed through a browser or app
Works offline?Yes, fullyNo, it needs an internet connection
CostFree and open sourceFree plans plus paid plans for teams
Main jobTrack history, branch and mergeShare repositories, review code, manage issues and pull requests
AlternativesMercurial, Subversion (older)GitLab, Bitbucket, Azure DevOps

Step 6 of 12Learn

Distributed: everyone has the full history

Older systems such as Subversion were centralized: the history lived on one server, and you needed a connection to commit or view history. If the server went down, everyone stopped.

Git is distributed. When you get a copy of a repository, you get the entire history, every commit back to the first one. You can commit, browse history, create branches and compare versions on a plane with no Wi-Fi. When you're back online, you exchange commits with other copies.

That raises the question of where the shared copy lives. Technically, any copy can talk to any other. In practice, teams agree on one copy hosted on a service like GitHub, and everyone sends their work there and gets others' work from there. GitHub adds features Git itself doesn't have: a web interface to browse code, pull requests for reviewing changes, issue tracking, project boards and automation.

A useful way to think about it: Git is like a word processor's track-changes feature, but far more powerful, and it lives on your machine. GitHub is like a shared drive built for Git projects, with discussion and review tools around it.

Step 7 of 12Practice · Diagram

What Git does, what GitHub adds

Where do pull requests belong?

Tap the shape that answers the question, then press Check.

What Git does, what GitHub addsVenn diagram: Git, GitHub, Git only, Git + GitHub (overlap), GitHub only.GitGitHub• Commits• Branches• Diffs• Local history• Full history• Pushed branches• Pull requests• Issues• Actions• Web code browser
Git

A free, open-source program on your computer. Works offline.

GitHub

A website: a hosting service built around Git repositories.

Git only
  • Commits
  • Branches
  • Diffs
  • Local history
Git + GitHub (overlap)

GitHub stores a real Git repository, so everything Git knows is there too.

  • Full history
  • Pushed branches
GitHub only
  • Pull requests
  • Issues
  • Actions
  • Web code browser

Step 8 of 12Practice · True or false

You need a GitHub account to use Git on your own computer.

Step 9 of 12Learn

What a repository is, and what belongs in one

A repository, or repo, is a project folder that Git is tracking. It looks like any other folder, plus a hidden subfolder named .git where Git keeps the whole history and its settings. Delete .git and the folder becomes ordinary again, with no history.

Git works best with plain text files: source code, HTML and CSS, Markdown, CSV, configuration files, scripts. For those, Git can show precisely which lines were added or removed. It can store binary files such as images, PDFs or Word documents, but it can only tell you that they changed, not how, and large binaries make a repository slow to copy.

Some things should never go into a repository:

  • Secrets such as passwords, API keys and private keys. Once committed, they live in the history.
  • Generated files that can be rebuilt from source, like compiled programs or dependency folders such as node_modules.
  • Personal clutter like editor settings and operating system files (.DS_Store, Thumbs.db).
  • Very large files such as videos and datasets in the gigabytes, which need separate storage.

You'll learn to exclude these automatically with a .gitignore file.

Step 10 of 12Practice · Sort into groups

Sort these into what belongs in a typical project repository and what should stay out.

Tap an item, then tap its group (or drag it there).

Step 11 of 12Timeline

A short history

  1. 2005
    Git is created

    Built for Linux kernel development after the project lost access to its previous tool.

  2. 2008
    GitHub launches

    Hosting plus a web interface makes sharing Git repositories easy.

  3. 2018
    Microsoft acquires GitHub

    GitHub keeps operating as a platform for open-source and private projects.

  4. 2020
    main becomes the default name

    GitHub starts naming the default branch of new repositories main instead of master.

Step 12 of 12Practice · Choose one

A five-person team wants to work on the same website code without emailing files and wants others to review changes before they go live. What is the most accurate description of their setup?