Week 8 Exercises - Git and GitHub

Short, ungraded practice tasks - about 40 minutes. Companion reading: Ch. 19; reference: App. H. HW2 goes out this week (due Monday, November 30): analyze the data, write it up in Quarto, record your environment, and push the repository to GitHub - these tasks are its on-ramp, and version-controlling your term project from today is the best possible practice.

  1. Check that Git is installed (git --version), then introduce yourself: git config --global user.name "..." and git config --global user.email "..." (use the email of your GitHub account), and set git config --global init.defaultBranch main.
  2. Turn your course folder into a repository: cd ~/projects/comptools && git init. Run git status and read what it says.
  3. Create a .gitignore that excludes data/ (large files do not belong in Git), the .quarto/ working folder, and any .DS_Store files.
  4. Stage and commit: git add . then git commit -m "First commit: course project skeleton". (Remember from class: you can also stage one file by name, or a set with a wildcard like git add *.R - . just means “everything from here down”.)
  5. Make an account at https://github.com if you do not have one, and create a new, empty repository named comptools.
  6. If you did not authenticate in class, do it now, once: gh auth login (GitHub.com → HTTPS → login with a web browser - the lecture’s authentication slide has the full prompts). Then connect and push, following GitHub’s “push an existing repository” instructions (git remote add origin ..., git branch -M main, git push -u origin main). Refresh the page - your files should appear.
  7. Edit your README.md locally, then - before staging - run git diff to see exactly what changed. Commit, push, and find the change in the History view on GitHub.
  8. Now edit the README on GitHub (the pencil icon), commit there, and git pull locally. Look at git log --oneline - you should see both commits, each with its short hash. Pick any two hashes and compare them: git diff <older> <newer>.
  9. Create a branch (git switch -c experiment), change a file, commit, switch back to main, and merge it.
  10. Deliberately break something: delete a tracked file with rm, then rescue it with git restore <file>. This is the safety net that makes the rest of the course’s habits pay off.
  11. Capstone: render your project’s Quarto report into docs/, add a .nojekyll file there (touch docs/.nojekyll, as in class), commit and push, then enable GitHub Pages (Settings → Pages → branch main, folder /docs). Open the live URL - that link is your reproducible project, ready for the December 11 submission.