version control, github, rstudio integration
2026-01-13
PhD Comics: notFinal.doc

Git is a robust version control system designed for text-based files
What? When? Who? Revert! plus:

A repository (or “repo”) is a project folder tracked by Git. Everything Git does is centered around repos.
Git repos can be local (on your computer) or remote (hosted on a server like GitHub).
Any folder on your computer can be turned into a Git repository (i.e. “initialized”), but a well-organized repo typically includes a few key components:
README.md, .gitignore, and .yml files (more on these later)GitHub: a web-based platform for hosting public and private Git repositories.
GitHub and Git are related, but not the same thing.
Git

GitHub
In this class we’ll use GitHub to:
But GitHub offers many more features, including:
A commit is the metadata associated with a change.
A shameful confession
I am a total hypocrite and rarely follow these guidelines. Actual commits from my actual repos:
oops i broke the kid data but the adult glms work now; omg i can't anymore here are some broken plots fix this later or don't i don't care; i need a drink
I’m not proud, but what matters is that you 1) commit often and 2) write messages that make sense to anyone who has to read them (including, hopefully, future you).
Your workflow:
Commit little & commit lots

Thou shalt:
Remember the whole point of GitHub is version control!
Each assignment has a unique repo. Each repo is a unique files.
Never create multiple copies of the same files!!!
merge conflict: Git cannot automatically reconcile differences between two versions of a file
Symbols like <<<, ===, and >>> mark conflicting sections.
All you have to do is change the text and delete the markers.
Local git repos are managed through the command line (Terminal on Mac, Git Bash on Windows)
Step 1: Set up your local workspace
Step 2: Do stuff. Make changes, additions, whatever in the repo files
Step 2.5: Commit your work frequently after every “nameable” change.

The git pane displays a list of all tracked files in your repo, along with their current status.

The git window opens when you click commit, diff, or history. It includes everything from the pane, plus:
What literally goes in your git repo?
A typical Git repository includes:
.git/) that Git uses to manage version control.yml options, bibliography files, themes, etc./localonly: only present in your local R Project, listed in your .gitignore and never synced to github/data: .csv/tabular data files for all raw or intermediate datasets read into in your .qmd, optional /raw subfolder for raw data read (only) into unsourced R scripts/source: .R scripts to be called in an early chunk of your .qmd, e.g., stylistic preferences, functions, minor data wrangling/images: exported figures and any image files to read-in to your R Markdown manuscript/_extensions: auto-generated or installed Quarto extensions, like apaquartoREADME.md: project overview, repo structure, to-do list, etc..gitignore: starting from the R .gitignore templateproject-manuscript.qmd: the home of your eventual publication bibliography.bib: a plain-text file containing all the BibTeX entries cited in your manuscriptyourCitationStyle.csl: the script used to format in-text and bibliography citations when knittingA simple, generic project:
quarto-manuscript-project/
├── README.md
├── .gitignore
├── project-manuscript.qmd
├── bibliography.bib
├── yourCitationStyle.csl
├── localonly/ // ONLY ON YOUR COMPUTER, NOT GITHUB
├── data/
│ ├── raw/ // Raw data read into unsourced R scripts
│ └── cleaned-data.csv // Processed data read into your .qmd
├── source/
│ ├── style-preferences.R // Styling/theming
│ ├── custom-functions.R // Reusable functions
│ └── data-wrangling.R // Minor data prep
├── images/
│ ├── figure1.png
│ └── figure2.png
└── _extensions/
└── apaquarto/ // Auto-generated extension files
.git/ - Git metadata, what makes Git work.Rproj.user/ - RStudio project settings.quarto/ - Quarto project settings.Rproj.RData.Rhistory.DS_StoreA README.md file provides a project overview. It is typically the first thing someone sees when they visit your repository on GitHub.
.md) document

A .gitignore file tells Git which files and directories to ignore when comparing differences between versions.

Not everything belongs online.
Optionally start with a template then:
# commentslocalonly/ folderIgnore large files
*.png, *.jpg, *.mp4*.pptx, *.key*.bdl, *.ear, *.mghIgnore auto-generated files
*.DS_Store, *.RData, *.Rhistory*.log, *.aux, *.out*.pdf, *.docx, *.htmlOptionally start with a template then:
# commentslocalonly/ folder
data/raw/sensitive_data.csv, topsecret/*.pdf, no-git_*Ignore large files
*.png, *.jpg, *.mp4
*.pptx, *.key
*.bdl, *.ear, *.mgh
Ignore auto-generated files
*.DS_Store, *.RData, *.Rhistory
*.log, *.aux, *.out
*.pdf, *.docx, *.html
README.md.gitignore fileD2M-R I | Week 2