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
1. link git to Rstudio
to make the link, first open the “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).
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.
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
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. 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 and then select the _git _option
7. paste the copied address
here it comes the moment to use the address copied at point 5.
8. give it a try
just to be sure everything is ok, you can commit whatever you like back to your Github repo.
the one that follows will be the output that will assures you your changes have been pushed to the Repository online.
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 .