Course outline · 0% complete

0/28 lessons0%

Course overview →

The problem Git solves

lesson 1-1 · ~9 min · 1/28

The problem Git solves

You already know your way around a terminal from The Terminal, Linux & Bash: you can cd into folders, create files, and run commands. Now imagine working on a real project for weeks.

Version control is software that records every version of your files, so you can see what changed, when, why, and by whom, and jump back to any earlier version.

Without it, projects die in familiar ways:

  • You improve a file, break it, and cannot remember what the working version looked like.
  • Your folder fills with report_final.txt, report_final_v2.txt, and report_final_REAL.txt.
  • Two people edit the same file and one person's work silently disappears.

Before learning the tool, let's feel the pain it removes. We'll do backups the manual way.

Code exercise · bash

Run this script. It manages versions the manual way: every time the recipe changes, we copy the entire file under a new name. Read the output and notice the clutter already starting.

Why manual copies fail

After two edits we already have three files. After a month we would have fifty, and the copies answer none of the important questions:

  • What changed between backup1.txt and backup2_final.txt? You would have to compare them by eye.
  • Why was the change made? No copy carries an explanation.
  • Which copy is safe to delete? Nobody remembers.

A version control tool fixes all three. It stores each version once, attaches a message, an author, and a date to it, and can print the exact lines that changed between any two versions on demand.

Code exercise · bash

Your turn. Create a folder called journal, put a file log.txt inside with the line "Day 1: started learning Git", copy it to day1_copy.txt, then append the line "Day 2: made my first backup" to log.txt. Finish with ls and cat log.txt so the output matches.

Quiz

A month into a project you have fifty manual copies like report_v2_final.txt. Which of the important questions can the copies answer on their own?

Git and GitHub are two different things

Git is the version control tool that won. It was created in 2005 by Linus Torvalds (the creator of Linux, which you met in the terminal course). It is free, it runs entirely on your own computer, and nearly every software company uses it.

GitHub is a website that stores copies of Git projects online so people can share them. Git is the tool, GitHub is a hosting service built around the tool. You can use Git your whole life without ever touching GitHub, and there are competitors to GitHub (GitLab, Bitbucket) that also host Git projects.

We spend the first six units purely on Git, on your machine. GitHub arrives in unit 7.

Quiz

A friend says "I don't need Git, I have a GitHub account." What's wrong with that sentence?