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
main
branch, and add a descriptive commit message.Confirm the commit.
Push the committed changes to GitHub.
Verify the changes on the GitHub repository page.
Bookdown Template in RStudio
- 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
- Open
index.Rmd
- Modify the YAML header and section titles to match your content
- Compile using the Build tab in RStudio
Publishing Using GitHub Pages
- Create a folder named
docs
and move compiled HTML files there - 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 > Manage Access > Invite a collaborator.
Enter the user’s name or email, assign appropriate access permissions, and send the invitation.