Quiz: Version Control & Collaborative Coding

Week 4 · Advanced Statistical Programming using R

Recap: Debugging

Q1

What is the main purpose of the {reprex} package?

  1. Automatically debug your R code
  2. Run code in a clean session and produce a self-contained snippet
  3. Replace the need for git commit
  4. Generate Personal Access Tokens for GitHub

Answer: 2) reprex::reprex() runs clipboard code in a fresh session and copies formatted output back.

Q2

Which of the following is NOT a typical Quarto rendering error?

  1. YAML syntax error (bad indentation, missing :)
  2. Missing image or data file
  3. Broken cross-reference (e.g. @fig-xxx with no label)
  4. Wrong number of arguments to an R function

Answer: 4) An R argument error happens during code execution. The others are pre-execution errors.

Git History & Workflow

Q3

Which is the best commit message according to the lecture?

  1. "fix"
  2. "changes to file"
  3. "Add penguin species filter"
  4. "It works. Don't touch!"

Answer: 3) Good commit messages are short imperative summaries describing what and why.

Q4

Which should NOT be committed to Git? (multiple correct answers)

  1. analysis.R — your main analysis script
  2. .env — API keys and credentials
  3. .Rhistory — R session history
  4. _site/ — rendered Quarto output

Answer: 2, 3 & 4. Only analysis.R belongs in Git. Secrets, session artefacts, and build outputs go in .gitignore.

Q5

How does Git internally store the changes you commit?

  1. As diffs between commits, applied sequentially
  2. As snapshots of all tracked files, each pointing to its parent
  3. As compressed file copies, named by date
  4. As a single text file that grows with each commit

Answer: 2) Each commit is a snapshot plus a parent pointer, author, timestamp, and message. Git shows diffs but doesn’t store them that way.

Q6

You deleted analysis.R two commits ago. Which command does NOT restore it?

  1. git checkout <hash> -- analysis.R
  2. git revert <hash>
  3. git pull origin main
  4. git diff <B> <A> | git apply

Answer: 3) git pull syncs with the remote — it doesn’t recover deleted files.

GitHub & Remotes

Q7

What is the key difference between forking and cloning?

  1. Forking is for private repos, cloning for public ones
  2. A fork lives on GitHub; a clone lives on your machine
  3. Forking only works in the browser, cloning on the CLI
  4. They are the same operation under different names

Answer: 2) A fork lives on GitHub. A clone lives on your machine.

Q8

You want to push a local repo to a new (empty) GitHub repo. Which sequence works?

  1. git push only
  2. git remote add origin <url>git branch -M maingit push -u origin main
  3. git fork <url>git push
  4. git clone <url>git push

Answer: 2) Connect the remote, set the branch name, push with -u to set the upstream. After this, git push works.

Q9

You run git push and GitHub rejects it. Most likely cause and fix?

  1. The remote has commits you don’t have — git pull first, then push
  2. Your commit message is too long — shorten and retry
  3. You forgot git init — initialise and retry
  4. GitHub is down — wait and try again

Answer: 1) A rejected push usually means someone pushed commits since your last sync.

Q10

Which two authentication methods does the lecture recommend for GitHub?

  1. Two-factor codes and biometrics
  2. HTTPS with a Personal Access Token, or an SSH key pair
  3. OAuth and OpenID Connect
  4. Email confirmation and CAPTCHA

Answer: 2) Either paste a Personal Access Token or set up an SSH key.