A repository is a collection of files, including code, data, and documents, that can be used to store multiple versions of files as the development of a project proceeds. Repositories can be local (i.e. file on the machine being used for development), but they are most effective if that are remote or offsite. Offsite repositories provide two important advantages: 1) they backup files that could be lost for any number of reasons (hard-drive failures, machine loss or meltdown), and 2) they are accessible from other machines, and by collaborators.
“Git” is one version-control system that creates and manages repositories (and note “Git” is purported not to mean anything), and “GitHub” is a website that hosts remote repositories, web pages, and some (smallish) data sets.
The use of Git and GitHub in R and RStudio is excellently described in the Bookdown document [Happy Git and GitHub for the useR (HappyGitWithR)] by Jenny Bryan at the Univ. British Columbia. This is the primary source for guidance and use of Git and GitHub from within RStudio.
The key steps include:
The basic idea is to create a (mostly) empty new repository on GitHub, and then “clone” to a local machine. The steps include:
At GitHub:
REarthSysSci
)README.md
fileOn the local machine:
~/Projects/DataVis/working/REarthSysSci
In RStudio:
https://github.com/pjbartlein/REarthSysSci
REarthSysSci
~/Projects/DataVis/working/
(note that .gitignore
, README.md
and REarthSysSci
have turned up in working directory)
Then, on the local machine:
README.md
and save (perhaps using a Markdown editor, or in RStudio)Tools > Version Control > Commit
Push
button to synchronize the local repository with the remote GitHub repository.