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 .
very useful… great tutorial… thank you Andrea Cirillo
You are welcome Alex, glad to be useful.
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?
Thank you very much for your detailed comment.
I have just updatet the post following your observations.
Thank you again.
You can get to a terminal/shell on any platform from RStudio – click the tools menu, then “Shell…”
Thank you for commenting. I have just updated the point 2. launch a terminal/shell in accordance with your suggestion.
Very useful. Thank you
you are welcome, thank you for commenting.
git config –global user.email “andreacirilloac@gmail.com”
thank you! just updated.