DEV Community

Cover image for How to push your project to GitHub from RStudio
Keith Karani
Keith Karani

Posted on

How to push your project to GitHub from RStudio

In this article, I write about a step-by-step walk through I had the opportunity to guide members of DeKUT {R} Community, a student led data science community in 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 which we will use to track changes to our project code.You can download from the appropriate version for your operating from https://git-scm.com/

Check Git version already installed

git --version
Enter fullscreen mode Exit fullscreen mode

To install Git on Ubuntu/Debian

sudo apt install git
Enter fullscreen mode Exit fullscreen mode

The last requirement you need is to create a github account, where we will create a repository to host out project source code. Navigate to https://github.com/ and signup

Creating a repository on GitHub

A repository is a "container" which holds all your projects files and each file revision history.

Give your repository an appropriate name and a brief description then, create repository.

Bravo! You have created a repository on GitHub.

Setting up your project on RStudio

Create a new project from 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 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 user name

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

Top comments (0)