From 7eb81852dcd6abb824f5376f84677c295c43901b Mon Sep 17 00:00:00 2001 From: Heli Juottonen Date: Thu, 19 Feb 2026 16:32:36 +0200 Subject: [PATCH] Add RStudio instructions --- content/index.md | 1 + content/rstudio.md | 18 ++++++++ content/ssh.md | 100 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 content/rstudio.md diff --git a/content/index.md b/content/index.md index 796e3a3..dddda9e 100644 --- a/content/index.md +++ b/content/index.md @@ -76,6 +76,7 @@ several options on how to participate (below). github vscode +rstudio editors git-in-terminal ssh diff --git a/content/rstudio.md b/content/rstudio.md new file mode 100644 index 0000000..6abfb4c --- /dev/null +++ b/content/rstudio.md @@ -0,0 +1,18 @@ +(rstudio)= + +# RStudio + +[RStudio](https://posit.co/products/open-source/rstudio) is a popular coding environment for R. It is **free and open source** and runs on your desktop and is +available for Windows, macOS, and Linux. +**If you are an R user and already use RStudio, we recommend to start with this one**. + +- To install RStudio, please visit the [download page](https://posit.co/downloads/) for + installation instructions. No specific settings are needed during installation to use Git. + +To set up RStudio with Git: + +- First, follow the first section of [Git in terminal](https://coderefinery.github.io/installation/git-in-terminal/) +on [Installation](https://coderefinery.github.io/installation/git-in-terminal/#installation) to make sure Git is installed on your computer. + +- Then, proceed to [SSH or HTTPS connection to GitHub from terminal](https://coderefinery.github.io/installation/ssh/) +and follow the RStudio tabs. diff --git a/content/ssh.md b/content/ssh.md index dde034f..3e545d8 100644 --- a/content/ssh.md +++ b/content/ssh.md @@ -47,9 +47,16 @@ If you use VS Code, authentication to GitHub happens automatically via if you use **HTTPS**. ```` +````{group-tab} RStudio +**If you use RStudio** + +If you use RStudio, authentication can happen either via HTTPS or SSH. Here, the RStudio instructions cover using **HTTPS**. + +```` + ````` -You should remember your choce for the lessons. +You should remember your choice for the lessons. @@ -119,6 +126,53 @@ No further setup is needed. VS Code prompts you to automatically handles the authentication when needed. ```` +````{group-tab} RStudio + +First, install the R package `usethis` if it isn't already installed: + +```r +install.packages("usethis") +``` + +Next, we set a user name and email to be used with Git by running this command in R: + +```r +usethis::use_git_config(user.name = "Firstname Lastname", user.email = "name@organization.org") +``` + +If you are unsure which email to use, use the one that you have registered at +GitHub with. + +**This name and email will be public on GitHub when you make +contributions, including in this course.** If you prefer to not use a real email address but still want to make sure that +GitHub counts your contributions, you can use +`yourusername@users.noreply.github.com` (replace `yourusername`). This is important since your Git commits use this information. + + +Then, let's create a Github token for HTTPS: + +```r +usethis::create_github_token() +``` + +This will open a Github web page. Give the token a name, for example related to the project you are working on, +and set the expiration date as you wish. In the section for scopes, the defaults are OK in most cases. +Generate the token. **Important: save the generated token on the clipboard or in a file, or keep the web page open.** The token can't be retrieved later and will be needed in the next step. + +To give the token to RStudio, run in R: + +```r +gitcreds::gitcreds_set() +``` + +Paste the token when prompted. Now you are ready to use Git with RStudio. + +If the token expires or gets lost, create a new one the same way. + +*Reference and more details on connecting RStudio, Git and Github: [Happy Git and Github for the useR](https://happygitwithr.com/)* + +```` + ````` @@ -208,7 +262,7 @@ it on a repository you have access to. class: dropdown --- If you are on a remote server and Git can't automatically start a web -browwser, you might get this prompt: +browser, you might get this prompt: ``` Select an authentication method for 'https://github.com/': @@ -221,5 +275,47 @@ Select option 1 and do what it says. ````` `````{group-tab} VS Code No further checking is needed (we hope). +````` + +`````{group-tab} RStudio + +In the RStudio console panel, click the Terminal tab. + +Run the following command: + +````console +$ git clone https://github.com/rkdarst/private-example.git +```` + +This is private so **it will say the repository is not found, but +that's OK.** This is what the output looks like if **the +authentication was successful:** + +````{code-block} console +--- +emphasize-lines: 3 +--- + +$ git clone https://github.com/rkdarst/private-example.git +Cloning into 'private-example'... +remote: Repository not found. +fatal: repository 'https://github.com/rkdarst/private-example.git/' not found +```` + +If authentification was not successful, you will see this: + +````{code-block} console +--- +emphasize-lines: 3 +--- +git clone https://github.com/rkdarst/private-example.git +Cloning into 'private-example'... +remote: Invalid username or token. Password authentication is not supported for Git operations. +fatal: Authentication failed for 'https://github.com/rkdarst/private-example.git/' +```` + +In this case, go back to the previous step and make sure you have created a token and +passed it to RStudio. + ````` ``````