In a few simple steps.
First and foremost why do we need it ?
Git is good at version control. So integrating R with git will help you manage all your codes and workspace in a proper manner.
You would need
- GitHub Account (If you don’t have a Github account you can create one here https://github.com/ )
- R-Studio (https://rstudio.com/products/rstudio/download/)*
- Git (https://git-scm.com/downloads)
- SVN (One of the many svn available https://tortoisesvn.net/downloads.html .You can explore other options too from apache or any other software vendors)
Once you have installed R-studio, Git and SVN
Open R-studio and click on tool from taskbar and navigate to Global Options
Navigate to “Git/SVN”. If you installation was performed correctly the directory to your git and svn will be mentioned.
Click on “Create RSA Key”. On the new Pop-Up select “Create”. The RSA file will be stores in a directory (You can choose your own desired directory too).
Click on “View public key” and copy all the contents inside it. The Key Begins with ‘ssh-rsa’, ‘ssh-ed25519', ‘ecdsa-sha2-nistp256’, ‘ecdsa-sha2-nistp384’ or ‘ecdsa-sha2-nistp521’ .
Open Browser and Sign in to Github
Go to your profile drop down and select settings.
On the settings page select “SSH and GPG keys” option
Paste the Key you copied in the Key Text Box. Add a title example R Studio. Once done Click add “SSH Key” It will be visible on the SSH key list
Let’s Create Repository for our project. There are multiple ways to create a repository. Click on the “+” icon near your profile picture on the top right and select “New Repository” on the drop down list.
- Name your Repository
- Add Description
- Choose if you want the mode to be private or public
- Check out the list of optional requirements (“README file”, “.gitignore” and “Choose a License”)
- Click on create repository
Copy the repository URL
Let’s go back on R-Studio and Create a new project
Select Version Control
Add the repository Url you copied and paste it in Repository Url box
Also select a subdirectory of the project and click on “Create Project”
Now your R-studio will have a git tab either next to “Connections Tab” or “Terminal Tab”
Create a new R-Script . And add your contents / Codes
Save the script. The file will appear on the Git tab.
To upload Tick the staged checkbox next to the file name and then click on commit or push as required
That’s all. You did it.
Follow me on GitHub https://github.com/enosjeba
*R-Studio requires R to be installed in order to wo