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.
- Check that Git is installed (
git --version), then introduce yourself:git config --global user.name "..."andgit config --global user.email "..."(use the email of your GitHub account), and setgit config --global init.defaultBranch main. - Turn your course folder into a repository:
cd ~/projects/comptools && git init. Rungit statusand read what it says. - Create a
.gitignorethat excludesdata/(large files do not belong in Git), the.quarto/working folder, and any.DS_Storefiles. - Stage and commit:
git add .thengit commit -m "First commit: course project skeleton". (Remember from class: you can also stage one file by name, or a set with a wildcard likegit add *.R-.just means “everything from here down”.) - Make an account at https://github.com if you do not have one, and create a new, empty repository named
comptools. - 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. - Edit your
README.mdlocally, then - before staging - rungit diffto see exactly what changed. Commit, push, and find the change in the History view on GitHub. - Now edit the README on GitHub (the pencil icon), commit there, and
git pulllocally. Look atgit log --oneline- you should see both commits, each with its short hash. Pick any two hashes and compare them:git diff <older> <newer>. - Create a branch (
git switch -c experiment), change a file, commit, switch back tomain, and merge it. - Deliberately break something: delete a tracked file with
rm, then rescue it withgit restore <file>. This is the safety net that makes the rest of the course’s habits pay off. - Capstone: render your project’s Quarto report into
docs/, add a.nojekyllfile there (touch docs/.nojekyll, as in class), commit and push, then enable GitHub Pages (Settings → Pages → branchmain, folder/docs). Open the live URL - that link is your reproducible project, ready for the December 11 submission.