Developing Code on Github

Objective

Learners will share their local repository on GitHub and learn how to sync some files while ignoring others systematically. Learners will practice developing new code on branches.

Lesson Outline

  • Review:

    • Ways of creating a git repo and how to know if it worked
    • (live coding) turn demo project from lesson 1 into a git repo with usethis::use_git()
  • Live Coding: working with git in RStudio

    • Demo add commit cycle with git pane AND git menu
  • Live Coding: .gitignore

    • Explore .gitignore created by RStudio
    • Software Carpentry .gitignore lesson
    • Discuss what files to .gitignore: what is “non-diffable”?
    • Modify and make a commit
  • What is GitHub and why use it? (slides)

  • Live Coding: GitHub setup

    • Go through checklist of usethis::git_sitrep() with student sharing screen
    • Don’t have student share screen with PAT generation! Switch to your screen!
  • Live Coding: Putting your code on GitHub

    • Local first: usethis::use_github()
    • GitHub first: create new repo on GitHub and create new R Studio project from version control
    • Other ways are possible, but we’re not going to cover them this lesson (unless someone has issues)
  • Live Coding: Push and Pull

    • Make changes in RStudio, push
    • Make changes on GitHub, pull
    • Have Renata make changes, push, then pull
  • Next time: How to work together on GitHub more safely

  • Homework: Put a personal repository on GitHub.

Installation & materials

  1. Slides
  2. Software Carpentry Version Control with Git episode #6
  3. GitHub authentication with PAT using Jenny Bryan’s Git book chapter 9 (follow usethis::git_sitrep())
  4. Software Carpentry Version Control with Git episode #7
  5. Software Carpentry branching add-on

Review

If anyone turned a folder into a repository, share how that went.

Teaching notes

  • Practice another add-commit cycle after creating the .gitignore
  • Introduce the add-commit-push cycle

Homework

Connect a personal repository to GitHub. Practice usethis::use_git() and usethis::use_github().

Citation

BibTeX citation:
@online{scott2023,
  author = {Scott, Eric and Diaz, Renata and Guo, Jessica and Riemer,
    Kristina},
  title = {Developing {Code} on {Github}},
  date = {2023},
  url = {https://cct-datascience.github.io/repro-data-sci//lessons/4-github-basics/notes.html},
  doi = {10.5281/zenodo.8411612},
  langid = {en}
}
For attribution, please cite this work as:
Scott, Eric, Renata Diaz, Jessica Guo, and Kristina Riemer. 2023. “Developing Code on Github.” Reproducibility & Data Science in R. 2023. https://doi.org/10.5281/zenodo.8411612.