Friday, June 5, 2026
Today: Friday June 5
Before class
Plan for today
Helpful links
filter, select, mutate, arrange, group_by, summarise) and grouped summaries.When you finish, turn in your quiz up front.
We’ve all probably done some version of the following:
analysis.R
analysis_v2.R
analysis_final.R
analysis_final_REAL.R
analysis_final_REAL_usethis_one.R
It sort of works, until you can’t remember which is which, or two people email versions back and forth and the changes get lost.
Tip
Version control is the tool built for exactly this problem. You can think of it as a time machine for your project.
A version control system lets you:
Instead of saving a new copy of every file each time, Git stores just what changed, so it can reconstruct any earlier version on demand.
Even if you’re working solo, version control is worthwhile; you might be:
Note
Paired with literate programming (Quarto), version control is what makes an analysis reproducible: a complete record from raw data to final result.
People often use “git” as a catch-all, but there’s actually two pieces:
| Git | GitHub | |
|---|---|---|
| What | The version-control tool | A website that hosts repos |
| Where | On your computer (local) | In the cloud (remote) |
| Job | Tracks changes, makes commits | Stores & shares the project |
A repo (repository) is just a folder Git is watching. It may include your .qmd files, data, images, etc. You keep a local copy on your computer and a remote copy on GitHub, and sync between them.
Most days, the whole workflow fits in four steps:
Tip
Commit early and often. Each commit is a labeled stop on the time machine. Lots of small, well-described commits are much more clear and easy-to-follow than one giant mystery commit.
The message is how you (and your teammates) navigate the history later without having to read through all of the various versions of your code.
# Helpful
"Add body-mass-by-species summary table"
"Fix na.rm bug in flipper-length means"
# Useless
"stuff"
"asdf"
"changes"
Note
If you commit with a vague message, you’ll have no idea what’s there without opening it.
Once Git is configured, you can get away with barely leaving RStudio. A Git tab appears in the top-right pane with:
This means we won’t need to mess with the command line for our project work.
I’ll run the full loop on the projector. Don’t follow along yet; just watch how the pieces connect. You’ll do it yourself this weekend.
Tip
Notice there was nothing about data analysis here. Git sits underneath the work you already do, simply creating snapshots and syncing the files.
For your project team:
GitHub (shared remote)
↑ push ↓ pull
┌─────┴─────┬───────┴─────┐
you teammate 1 teammate 2
| Symptom | Cause | Fix |
|---|---|---|
| Merge conflict | Two people changed the same lines | Git asks you to pick; pull/push often to avoid |
| “My changes aren’t tracked!” | Wrong RStudio Project open | Switch to the Project tied to that repo |
| Push rejected | A teammate pushed first | Pull, then push again |
| File-too-big warning (>50 MB) | Committing a big data file | Don’t commit it; add to .gitignore |
Warning
When truly stuck, Happy Git’s troubleshooting chapter and the “Burn it all down” escape hatch (re-clone a fresh copy) will probably help.
Solo: follow Happy Git with R to register on GitHub, install Git, connect it to RStudio, and prove it works with a test repo.
Team: one person creates the project repo and adds the others as collaborators; everyone clones it and pushes at least one commit.
Upcoming Deadlines
Reach out
Stuck? Office hours, or email me (cgc5478@psu.edu) or Xinyue (xpw5228@psu.edu).
Reference
Syllabus · AI policy · Schedule · Happy Git with R · DC Ch. 9 · GitHub