Developing Code on Github
Objective
Learners will share their local repository on GitHub and learn how to sync some files while ignoring others systematically. They’ll get the basics of working by themselves with GitHub (push/pull from main branch only) using RStudio.
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
- Demo
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
- Explore
What is GitHub and why use it? (slides)
Live Coding: GitHub setup
- Before this lesson run
gitcreds::gitcreds_delete()
to simulate a brand new setup - Go through checklist of
usethis::git_sitrep()
- Remove the token you create before video is posted
- Before this lesson run
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)
- Local first:
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
- Slides
- Software Carpentry Version Control with Git episode #6
- GitHub authentication with PAT using Jenny Bryan’s Git book chapter 9 (follow
usethis::git_sitrep()
) - Software Carpentry Version Control with Git episode #7
- 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{scott2024,
author = {Scott, Eric and Diaz, Renata and Guo, Jessica and Riemer,
Kristina},
title = {Developing {Code} on {Github}},
date = {2024},
url = {https://cct-datascience.github.io/repro-data-sci/lessons/5-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. 2024.
“Developing Code on Github.” Reproducibility & Data
Science in R. 2024. https://doi.org/10.5281/zenodo.8411612.