2 min read

How to use Github with Rstudio : step-by-step tutorial

andreacirilloac

Pushing to my Github repository directly from the Rstudio project, avoiding that annoying “copy & paste” job. Since it is one of Best Practices for Scientific Computing, I have been struggling for a while with this problem.  Now that I managed to solve the problem, I think you may find useful the detailed tutorial that follows. I am not going to explain you the reason why you should use Github with your  Rstudio project, but if you are asking this to yourself, you may find useful a Stack Overflow discussion on the topic.

0. download last git version

you can download the last git version from Git website git logo

to make the link, first open the “global options” global options after selecting the “GIT/SVN” tab, you will have to find the “git.exe” file within your Mac (if you are using Windows, give a look to the comment by Rajesh here below). fin git

2. launch a terminal/shell

the quickest way to launch a terminal/shell, from whatever operative system you are working in, is within Rstudio itself, in the tools menu, as observed by Hadley Wickham in his comment below. launch shell

3.type those words

once you have your terminal session open, you just have to type-in those words:

  • git config --global user.name "AndreaCirilloAC"

  • git config --global user.email "andreacirilloac@gmail.com" 

you have to do this once in your life, or at least once for each user on your Mac… Just to be sure… you should put your username and and your e-mail address

4. create a repository on Github

repository

5. copy the repository ssh address

the link between GithHub and Rstudio will be the Github repository address. Be sure to copy it  from the repo main page, using the SSH “version”, as shown in the picture. copy address I am suggesting the SSH address, due to a bug on latest Rstudio Version.

6. create a new Rstudio project

after selecting the _new project _control, select the version control option new project and then select the _git _option choose git

7. paste the copied address

here it comes the moment to use the address copied at point 5. paste ssh

8. give it a try

just to be sure everything is ok, you can commit whatever you like back to your Github repo. commit 1 commit 2 the one that follows will be the output that will assures you your changes have been pushed to the Repository online. result I hope it was clear enough, but if you need any further clarification do not hesitate to ask for it here below or on twitter @andreacirilloac .

comments disclaimer
thank you for taking the time to comment. If the comment you are about to write is related to a piece of code I wrote, please reach its Github respository and place there any request of improvement or report of bugs.