Adapted from Happy Git and GitHub for the useR
2024-06-20
Git: free & open source version control system.
GitHub: hosting service/platform for Git-based projects on the internet (aka RStudio projects in our case).
For software developers, researchers, government agencies, your future self, and anyone who needs a robust version control system and collaboration!
Git & GitHub are not the same thing, like R & RStudio are not the same thing.
Install Git from https://git-scm.com/install.
Close and re-open RStudio.
Check that it’s installed in the Terminal in RStudio by running:
Note
You should see something like: git version 2.37.1.windows.1
If you see something like git: command not found, Git was not successfully installed.
See https://happygitwithr.com/install-git#install-git for more help.
Use the email associated with your GitHub account.
macOS users
If you get an error, try installing XCode command line tools by following these instructions: https://happygitwithr.com/install-git#macos.
Restart RStudio and try again.
Generate token from https://github.com/settings/tokens or:
Select expiration period, ensure selected scopes include “repo”, “user”, “workflow”, then click “Generate token”.
Copy the token and save it somewhere safe. Treat it like a password.
Securely store it in RStudio with the gitcreds package.
Run this in the console
to get this prompt for your token (not your login password):
Clone the test repo to your computer:
RStudio > File > New Project > Version Control > Git
Paste the URL copied from GitHub into “Repository URL”.
Leave the default project directory name the same as the GitHub repo name.
Intentionally choose where to save this project locally.
Click “Create Project”.
Clean up:
Quit the RStudio project.
Delete the project folder.
Delete the remote on GitHub. Settings > Danger Zone > Delete this repository > do as it asks.
Problems with Chapters 11 & 12?
repository or repo: set of files in a folder
clone: local version of a repo
remote: the repo on GitHub
stage: prepare a file or files for a commit
commit: snapshot of all files in the project
diff: differences between commits
push: uploads all commits to GitHub
Figures from (Bryan 2018)
https://github.com/WA-Department-of-Agriculture/washi-sos
Clone washi-sos to your computer (step 3 of Ch 11 & 12) using this repo URL:
Click the Pull button in the Git pane of RStudio to copy changes from the remote repo on GitHub to your local repo.
For educational fun:
Integrating Luis’ work on the management data
Option 1: Luis works in a separate repo with a “final” dataset folder that I manually or automatically pull in to the master washi-sos repo? WSDA or WaSHI organization?
Option 2: Luis works in washi-sos with push/pull access. Careful to communicate and avoid merge conflicts.
GitHub vs Sharepoint vs Shared Drives: too many copies to maintain
More GitHub trainings?