Link your GitHub Account with R Studio
Last Updated : 29 Mar, 2023
R Studio is an integrated development environment(IDE) for R Language. IDE is a GUI, where you can write your quotes, see the results and also see the variables that are generated during the course of programming. R Studio is available as both Open source and Commercial software. It is also available as both Desktop and Server versions and also available for various platforms such as Windows, Linux, and macOS.
Git is an open-source version control system. It means that whenever a developer develops some project (like an app) or something, he/she constantly update it catering to the demands of users, technology, and whatsoever it maybe. Version control systems keep these revisions straight, storing the modifications in a central repository. It allows developers to easily collaborate, as they can download a new version of the software, make changes, and upload the newest revision. Every developer can see these new changes, download them, and contribute. Git is used to storing the source code for a project and track the complete history of all changes to that code, while GitHub is a cloud-based platform built around the Git tool. So it’s necessary to upload your project on GitHub.
Prerequisite: Before going through this article consider that one must already have a GitHub account along with R studio installed on their computer.
Now we have both RStudio and a GitHub account, it’s time to link them together so that you can maximize the benefits of using RStudio in your version control pipelines. Here is the step by step process to link GitHub and RStudio.
Step 1: In RStudio, Go to Tools > Global Options > Git/SVN
Then click on Create RSA Key and when this completes, click Close. Following this, in that same window again, click View public key and copy the string of numbers and letters. Close this window.

Now you have created a key that is specific to you which we will provide to GitHub, so that it knows who you are when you commit a change from within RStudio.
Step 2: Now Go to github.com, log-in if you are not already, and Go to your account settings. There, Go to SSH and GPG keys.

Now click New SSH key. Paste in the public key you have copied from RStudio into the Key box and give it a Title related to RStudio. Confirm the addition of the key with your GitHub password.

GitHub and RStudio are now linked. From here, we can create a repository on GitHub and link to RStudio.
Step 3: Now let's create a new repository and edit it in RStudio. On GitHub, create a new repository(github.com > Your Profile > Repositories > New). Name your new test repository and give it a short description. Click Create Repository. Copy the URL for your new repository.

Step 4: In RStudio, Go to File > New Project. Select Version Control.

Then Select Git as your version control software. Paste in the repository URL from before, select the location where you would like the project stored. When done, click on Create Project. Doing so will initialize a new project, linked to the GitHub repository, and open a new session of RStudio.
Step 5: Create a new R script(File > New File > R Script) and copy and paste the following code and save the file.
R print("This file was created within RStudio") print("And now it lives on GitHub")

Once that is done, looking back at RStudio, in the Git tab of the environment quadrant, you should see your file you just created. Click the checkbox under Staged to stage your file.

Then click Commit. A new window should open, that lists all of the changed files from earlier, and below that shows the differences in the staged files from previous versions. In the upper quadrant, in the Commit message box, write yourself a commit message. Click Commit. Close the window.

So far, you have created a file, saved it, staged it, and committed it the next step is to push your changes to your online repository. Push your changes to the GitHub repository and you are done.

Similar Reads
How to Add SSH Key to Your GitHub Account? An SSH (Secure Shell) key is a pair of cryptographic keys used for authenticating and securing network communications over the SSH protocol. SSH keys are commonly used to securely access remote systems, transfer files, and execute commands on remote machines without passwords. Components of an SSH K
3 min read
How to Link GitHub with Visual Studio? Linking GitHub with Visual Studio allows you to manage your code repositories, collaborate with others, and streamline your development workflow directly from your IDE. Visual Studio provides integrated tools for cloning, creating, and managing GitHub repositories. Prerequisite:Visual Studio install
1 min read
How to Setup Git on Anypoint Studio? Git is essential software for developing purposes. Every developer uses Git as a backup of their work. Git is a type of Version Control System. It falls under the Distributed type of the Version Control System. There is also much another software present that serves the same as Git. But Git is famou
5 min read
How to Add Github to Linkedin? Adding a GitHub profile to LinkedIn is a great way to showcase our coding projects, contributions, and technical skills. This can enhance our LinkedIn profile by providing potential employers and professional connections with direct access to our work. There are multiple ways to add your GitHub to L
2 min read
How to Install R and R Studio? Navigating the R language installation process and setting up R Studio is crucial for anyone looking to delve into data analysis, statistical computing, and graphical representation with R. In this article, we provide a step-by-step guide on how to install R and configure R Studio on your system. Wh
6 min read