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

Example: Modify a Test Repository

  1. Clone the repository and locate the Git tab in RStudio.

  2. Pull the latest version of the repository.

  3. Edit the README file and commit changes.



  • Stage the modified files, ensure you are working on the main branch, and add a descriptive commit message.

  • Confirm the commit.

  1. Push the committed changes to GitHub.


  2. 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 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 or quarto render in 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 docs so you do not have to move files by hand:
    • Quarto Book: set output-dir: docs under the project: key in _quarto.yml.
    • Bookdown: set output_dir: "docs" in _bookdown.yml.
  • In GitHub repository settings, set Pages source to the docs folder
  • 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.

Useful Resources