How to push your project to GitHub from RStudio
Table of contents
In this article, I will take you through the step-by-step walkthrough I had the opportunity to guide members of DeKUT{R} Community, a student-led data science community at Dedan Kimathi University in Kenya during our semester weekly meetups.
To begin with, you have to install R from the Comprehensive R Archive Network CRAN https://cran.r-project.org/
Type R --version on the terminal to view the version of R you have installed.
Secondly, install RStudio IDE which is the best coding environment for R built by Posit https://posit.co/downloads/
RStudio IDE Screenshot
Another requirement is Git. Git is a version control system that we will use to track changes to our project code. You can download the appropriate version for your operation from https://git-scm.com/
Check the Git version already installed
git --version
To install Git on Ubuntu/Debian
sudo apt install git
The last requirement you need is to create a GitHub account, where we will create a repository to host our project source code. Navigate to https://github.com/ and signup
Creating a repository on GitHub
A repository is a "container" which holds all your project files and each file revision history.
Give your repository an appropriate name and a brief description then, create a repository.
Bravo! You have created a repository on GitHub.
Setting up your project on RStudio
Create a new project and select the Version Control option on the new project wizard
Select version control
In the new project wizard select GIT as your version control to use
Remember the repository we created on GitHub, it is time to use the repo's URL.
Copy the repository URL and paste it on the Repository URL text box as shown below and click Create Project.
Load your project
For this article, I conducted exploratory data analysis and data visualization on the Titanic data in a markdown file.
To stage my file ready for commit, navigate to the Git Tab in the Environmental pane of the IDE.
Check the files you wish to stage for commit and click 'commit'.
The RStudio commit changes window will pop up, where you can view the project files and add a commit message as shown below.
Add a suitable commit message and commit your staged files.
At this point, you have completed a commit of your files and they are ready to be pushed to GitHub.
Close the Git Commit window and click the green Push arrow above the commit message text box.
You will be prompted to provide your GitHub username
Provide your generated GitHub access Token as your password and click OK.
Learn how to get your personal access token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
DONE!
You have successfully pushed code from RStudio to GitHub
You can verify this by switching back to your GitHub account on your browser and navigate to your project repository in my case Jaribio.
The repository link to visualizing Titanic is available here https://github.com/KaraniWachira/Jaribio
Thank you for reading!
DeKUT {R} Community Twitter: https://twitter.com/RDekut
Subscribe to my newsletter
Read articles from KaRani Keith directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by