Our GitHub workflows

Today’s goals

  1. Check git and GitHub are talking
  2. Define our GitHub workflow for the remainder of the semester
  3. Fork and clone the class repo

Workflow

The workflow presented next is what you will always do when starting a new exercise (I’ll let you know when that happens). I’ll tell you

“Create a GitHub workflow for an exercise called 03_crd”

  • Let’s walk through what I’ll expect you to do:

Can you hear me?

These steps were outlined on chapter 12: Connect Rstudio to Git and Github:

  1. Make a repo on Github
    • Name: 03_crd
    • Description: no description
    • Make it public
    • Check the box for Add a README file (always recommended)
    • Add a .gitignore: select R
    • Create repository

Can you hear me?

  1. Clone your repo
    • Click on the <> Code button
    • Choose HTTPS
    • Copy the path

Can you hear me?

  1. RStudio Project
    • Launch RStudio
    • File > New Project > Version Control > Git
    • Repository URL: Paste GitHub URL
    • Project directory name: leave blank
    • Create project as subdirectory of: browse to this course main folder in your computer (where you see other project folders like 01 intro)
    • Create Project

Can you hear me?

  1. From changes to commits
    • From RStudio, launch your README, edit it, save it

    • Can you see the Git pane next to the environment? If not, then do View > Show git

    • Under Staged, check the box for README.md

    • Click on the checkmark icon (to commit)

    • Under commit message, write something short yet informative (e.g., updated readme)

    • Click on Commit, close log window

Can you hear me?

  1. Push to GitHub
  • Back on Git pane, click on the green up arrow to push your changes
  • Close log window
  • On browser, refresh github repo page

Did you hear me?

Did it all work? If yes, then you are all set to use git and GitHub! 🥳

If not, then we’ll need to troubleshoot it.

Forking the class 2024_dsa repo

Next, let’s Fork and Clone the class repo, so you won’t need to do manual downloads anymore.

Detailed instructions found here

Forking the class 2024_dsa repo

  1. Copying the URL

Forking the class 2024_dsa repo

  1. Forking and cloning with {usethis}
  • Open any RStudio window
  • On the console, copy the code below (copy button on top right corner), edit destdir and run in the console:
usethis::create_from_github(
  "https://github.com/leombastos/2024_dsa.git",
  destdir = "~/path/to/where/you/want/the/local/repo/",
  fork = TRUE)

Forking the class 2024_dsa repo

Now, anytime I have new code or data files, all you need to do is:

  • Launch that RStudio Project
  • On the Git pane, click on the green down arrow to pull the updates
  • Move your local copies of the new files into your own project folder and appropriate sub-folders