10 Introduction to version control
Goal 🎯: By the end of this chapter, you’ll understand the benefits of using version control to track changes in your coding projects, and how Git and Github allow us to store these versions online.
10.1 Introduction to Version control
Version control is a system that helps you track and manage changes to files over time. It lets you save different versions of your work, go back to earlier versions if you make a mistake, and work with other people without overwriting each other’s changes.
So what does this look like in practice?
Let’s imagine for a moment that you’re writing a paper. Every time you make a big edit, you save a new copy: paper_v1.docx
, paper_v2.docx
, paper_final.docx
, etc.
It’s easy to see how it could become difficult to keep track of which version was which using this kind of a system. Now, imagine how much messier and unwieldy it could become trying to keep track of different versions of an R project with changes in multiple .qmd
files AND with multiple people making edits to those files ➡️ enter version control.
Version control keeps track of these different versions for you so you don’t have to. Have you ever used the versions
feature in Google docs when working on an article draft? Then you’ve interacted with a type of version control.
10.2 What is Git?
To keep track of versions of coding projects, programmers use a version control tool called Git. It runs on your computer and helps you:
- Track changes you make to your project files.
- Save “snapshots” (called commits) of your project over time.
- Go back to an earlier snapshot if needed.
- See what exactly changed between versions.
- Work with teammates without messing up each others’ work.
You can think of Git like the “save game” feature on a video game. Instead of saving the progress of your character in your game, Git saves your progress in your coding files. But just like in many games, we have to tell Git when and how to save a new version.
This is where Github comes in.
10.3 What is Github?
GitHub is a website that hosts Git repositories (your project + its history) online.
Github lets you:
- Store your Git project safely in the cloud.
- Share your project with others.
- Collaborate with other people (even if they are far away).
- Keep a backup in case your computer crashes.
If Git is a notebook where you track all your work, GitHub is like an online library where you can store a copy of that notebook — and invite others to read it or even help you write in it.
10.4 Checkpoint
In this chapter you learned some about version control and the tools we use to access it.
Let’s quickly recap those tools before moving on:
- Version control: the system of tracking changes to your files over time so you can revisit or undo edits, collaborate with others, and keep a history of your work.
- Git: a version control tool you use on your computer to track changes.
- GitHub: a website where you can upload (and share) your Git projects.
Next up:
We’ll install Git and get our computers setup to start tracking changes. When you’re ready, move onto the the next chapter.