Part IV: git and GitHub

- R project management series -

Athanasia Monika Mowinckel

31.03.2022

This is a crash course

Series talks

Part I - RStudio projects
Part II - Organising your files and workflow
Part III - Package / Library management
Part IV - git & GitHub crash course!
Part V - quarto / Rmarkdown

git - what?

  • version control system

  • tracks changes in files and folders

  • tracks changes to text in text files

  • command line based

git - why?

  • tracks all changes to files

  • with comments

  • with information on who did the change

  • with timestamp

git - why?

  • changes can be undone, without loosing history

  • changes from different users that “collide” need human interaction to resolve

  • only changes are saved, so storage space needed is small

git - workflow

GitHub - what?

  • cloud storage system

  • storage of git data

  • online git collaboration platform

GitHub - why?

GitHub - workflow

Working locally with git, and storing on GitHub for collab

git & GitHub branching

git / Gitea example - NOAS

git lingo

command where meaning
repository / repo a git project, has a .git folder with all information about the files and history of files.
clone repo copy Create a local copy of entire repo, with all history and files.
fork repo copy on GitHub A copy of the entire repo, with all history and files, on GitHub

git lingo

command where meaning
pull / fetch GitHub to local get update from GitHub on new files and changes
push local to GitHub send local changes to GitHub
pull request (PR) GitHub a request to merge a branch’s into another branch
branch a deviation from a main history line to isolate work on specific tasks

git lingo

command where meaning
add local add changes/files to temporary cache
cache/stage uncommitted storage files and changes added to git, but not yet committed to memory. Temporary, forgettable storage
commit commit cache to history commit everything in cache to git history with a message

.gitignore

Make sure that files/folders that contain certiain information does not end up in your repository

Use the .gitignore` file to make sure things never are added to git history

gitignore

  • any data connected to single individuals
  • comments connected to single identifiable data points
> cat .gitignore
data/
my_file.txt

# R stuff to ignore
.Rhistory
.Rproj.user

# Mac hidden storage
.DS_Store

More resources