Two people, one file
Sam and Aisha both change the same file. Sam saves at 10:00. Aisha saves at 10:05. Sam's work is gone.
Teams solve this with version control. Version control is a tool that keeps every version and joins changes safely. Even when you work alone, it protects you.
Key words
| Word | What it means | Example |
|---|---|---|
| Version control | A tool that keeps every saved version of your work. | Git |
| Repository | A folder that holds your project and its history. | hillside-tool |
| Commit | A saved step in the history, with a short message. | Add leave_waiting_list |
| Branch | A separate line of work. You can join it back to the main work later. | waiting-list |
| Pull request | A request to join your branch into the main one, so others can review it. | Add the waiting list |
| Code review | Another person reads your code and gives feedback. | a checklist |
| Pair programming | Two people work at one computer. One types and one watches. | one person types, one person checks |
| Merge | Join the work of a branch into the main version. | join waiting-list into main |
| Function | A named piece of code that does one job. | next_in_line() |
| Readability | How easy the code is for a person to read. | clear names |
The cells students fill in are left blank in this preview.
The Git commands in this lesson
| Command | What it does |
|---|---|
| cd hillside-tool | Goes into the folder |
| echo "text" > waiting.py | Makes a file called waiting.py with that text in it |
| git init hillside-tool | Makes a new repository in a folder called hillside-tool |
| git status | Shows which files changed |
| git add waiting.py | Chooses a file for the next commit |
| git commit -m "message" | Saves a step with a short message |
| git log --oneline | Shows the history, one line each |
| git checkout -b waiting-list | Makes a new branch and moves to it |
The cells students fill in are left blank in this preview.
Start the lab first
data-callouts.note.label
Press Start the lab on the bar at the top of this lesson. Wait until it says it is running. Each Run button types a command into your lab terminal. Every command makes a new practice folder, so nothing important can break. Never run a command you do not understand.
Step 1: make a repository
git init hillside-toolA command for the lesson’s lab terminal. It is shown here and not run.
Step 2: go into the folder
cd hillside-toolA command for the lesson’s lab terminal. It is shown here and not run.
Step 3: make a file
echo "# Hillside waiting list" > waiting.pyA command for the lesson’s lab terminal. It is shown here and not run.
Step 4: ask Git what it sees
git statusA command for the lesson’s lab terminal. It is shown here and not run.
What did you see?
Have a go
What did you see?
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.