Updating Repository Contents from RStudio
This section outlines how to update the contents of a cloned GitHub repository using RStudio. It also introduces key Git commands and common workflows for version control and collaboration.
Example Git Workflow in RStudio
Git is used through a series of commands. The most commonly used are:
- pull: Retrieves the most recent version of the repository, ensuring all local files are up to date.
Always begin your session by pulling changes to prevent conflicts. See this video for guidance on resolving merge issues.
- commit: Records a snapshot of changes made to local files.
Write clear, concise commit messages to help collaborators understand the purpose of each change.
- push: Uploads committed changes to the remote repository on GitHub.
Conflicts may arise if changes contradict those already made in the repository. See this video for resolving conflicts in RStudio.
Additional Git commands and advanced options are available in the Git documentation.
Requirements and Necessary Software
- A GitHub account
- R and RStudio (refer to previous chapter)
- GitHub Desktop
Example: Modify a Test Repository
Clone the repository and locate the Git tab in RStudio.

Pull the latest version of the repository.

Edit the README file and commit changes.


Stage the modified files, ensure you are working on the
mainbranch, and add a descriptive commit message.
Confirm the commit.

Push the committed changes to GitHub.


Verify the changes on the GitHub repository page.

Book Template in RStudio
This OER itself is built as a Quarto book, so the Quarto workflow below is the recommended option. The older bookdown workflow is included as an alternative.
Option A: Quarto Book (recommended)
- Go to File > New Project > New Directory > Quarto Book
- Name your project (e.g.,
"test1") - Copy project files to your main repository folder
- Edit
index.qmdand the chapter.qmdfiles to match your content
Option B: Bookdown
- Go to File > New Project > New Directory > Book Project using bookdown
- Name your project (e.g.,
"test1") - Copy project files to your main repository folder
- Rename the project file as appropriate (e.g.,
"template")
Compiling
- Quarto Book: open
index.qmd, modify the YAML header (_quarto.yml) and section titles to match your content, then render using the Render button orquarto renderin the Build tab. - Bookdown: open
index.Rmd, modify the YAML header and section titles to match your content, then compile using the Build tab in RStudio.
Publishing Using GitHub Pages
- Have the build write its HTML directly into a folder named
docsso you do not have to move files by hand:- Quarto Book: set
output-dir: docsunder theproject:key in_quarto.yml. - Bookdown: set
output_dir: "docs"in_bookdown.yml.
- Quarto Book: set
- In GitHub repository settings, set Pages source to the
docsfolder - Your site will be available at
username.github.io/repository_name
Invite Collaborators
Navigate to your repository > Settings > Collaborators (under the “Access” section) > Add people.
Enter the user’s name or email, assign appropriate access permissions, and send the invitation.