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

1. link git to Rstudio

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 .

Advertisements

10 thoughts on “How to use Github with Rstudio : step-by-step tutorial

  1. Thanks so much for sharing.

    As a note – I kept having issues as I was initially pointing to git.exe in C:\Program Files (x86)\Git\libexec\git-core instead of the one in the “bin” subfolder.

    I also agree that you have to use the HTTPS url – I couldn’t get it to work with the SSH version. Did you think about editing Instruction #5 to make that more clear?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s