How to push your project to GitHub from RStudio
Tags: github, datascience, r, rstudio
Published: 2022-12-29 09:38:43

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/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00qb34p15wae966tmz5h.png)
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/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdq04khxdrt0lhl591jm.png)

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/ 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ianz2yqnbxglbnolb34c.png)

Check 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 out project source code. Navigate to https://github.com/ and signup

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/peeylwxrht2mvuj6iidu.png)

**Creating a repository on GitHub**

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14gyzfijah1aralpd8tz.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rpmc0q9teoyx7il1ddcy.png)

Bravo! You have created a repository on GitHub. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thh6jnplu8s2ii325u0d.png)

**Setting up your project on RStudio**

Create a new project from and select the Version Control option on the new project wizard

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q9cmlpk26vjbjqlmm3xv.png)

Select version control 

In the new project wizard select GIT as your version control to use

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mewvpmn2bx4elzmrhirx.png)


Remember the repository we created on GitHub, it time to use the repo's URL. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnux8kmfmpqseknkw4ga.png)

Copy the repository url and paste it on the Repository URL text box as shown below and click Create Project.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sr5rct767q55xujhvb6s.png) 

**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. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/owgqgo5ap03mlselpbtv.png)

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.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7wpz3r7g0wdspczzmjy.png)

Add a suitable commit message and commit your staged files.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4fe7bfxtnfqxj3whw4tb.png)

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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0wg1tc3fpzrxvsr6paff.png)

You will be prompted to provide your GitHub user name

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nofbiv5uc7fu821ts7np.png)

Provide your generated GitHub access Token as your password and click OK. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gh9jkpld680izcmd1yjy.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9194syvcihfou5xji0ek.png)

You can verify this by switching back to your github account on your browser and navigate to your project repository in my case Jaribio.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5nrd37fi61jpib7hdwn.png)

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