GitHub is a hosting service (like a Cloud) that allows version-control and source-code management (i.e., tracking changes on files). GitHub is similar to Google Docs with the ability to collaborate on single documents and projects. Though, GitHub has more strucuture for collaborations on files, which are discussed here.
Requirements to use:
GitHub Account - This is your account to use the “cloud”
RStudio - RStudio can directly integrate with GitHub. This allows you to make local changes (i.e., changes on your computer) to a file and add them to the GitHub cloud
GitHub Desktop - This allows you to integrate with GitHib for files outside of R. This is not required if you are only using R and GitHub.
Repository: A repository is the most basic element of GitHub. They’re easiest to imagine as a project’s folder. A repository contains all of the project files (including documentation), and stores each file’s revision history. Repositories can have multiple collaborators and can be either public or private.
Committing Similar to saving a file that’s been edited, a commit records changes to one or more files in your branch. Git assigns each commit a unique ID, called a SHA or hash
Pushing: To push means to send your committed changes to a remote repository on GitHub.com. For instance, if you change something locally, you can push those changes so that others may access them.
Pulling/Pull Requests: Pull requests let you tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
In order to publish files from RMarkdown to GitHub you must have (1) a GitHub repository for the files to be stored in, and (2) RStudio linked to GitHub via RProject
A. In the upper-right corner of any page on your GitHub, use the drop-down menu, and select New repository. Name your repository as desired (e.g., pupil-project). Describe it as needed (e.g., this project will optimize our pupilometry pipeline). Choose your visibility (Public or Private).
B. Choose “Initialize this repository with a README. Click”Create repository"
C. Now that your repository has been created. Select it from your GitHub homepage. Choose the “Code” dropdown menu and copy the HTTPS URL (we need this to link the GitHub repository to our RStudio Project.)
Green box, top right to see URL code
A. In RStudio select File > New Project > Version Control > Git. In the “Repository URL” paste the URL of your desired GitHub repository. In the “Project Directory Name:” specify the Project Name you would like. In the “Create Project as Subdirectory of:” select the subfolder of choice.
B. Click “Create Project”. This will create (1) a folder on your computer with the Project name, (2) a local Git Repository linked to your remote Git repository, and an RStudio Project.
This will create a Git tab
A. With your repository open, select the “Settings” tab. This will bring you to a new page. Scroll until you see “Danger Zone” subheading, and select “Change visibility”.
Images
A. Open the repository where the image is stored and select the image. With the image selected, click the “Download” button. This will give you the raw HTTPS path to be copied into your Markdown.
B. Paste the link with the code below:
<img src="https://raw.githubusercontent.com/maxflurie/test2/master/coglab_logo20.png" width="300">
#Note we also see an option at the end to specify the size
This will show as:
Style Sheets
A. To insert a style sheet from your computer, you can use the r package ‘here’ to specify your chosen CSS. With your CSS in the same folder as your Markdown, simply use the following code to designate the path:
css: !expr here::here("/yourCSS.css")