Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repo from RStudio to Github

Tags:

I love github and RStudio for workflow. Recently, I've created a project template that makes directories and scripts etc. and would like to create locally and push to github.

In the past I created a repo for a project via https://github.com/ used version control in RStudio to create the local repo and then dump all files I already had there.

This seems wasteful of time. How can one to take the directory/repo that's already in RStudio with a .Rproj file and upload to github with out first creating the shell repo at https://github.com/?

I think this could save time in the workflow.

I thought I could just follow the directions -here- (under Adding version control to a project) to add version control but this doesn't allow me to push to github (nor should it because how does RStudio know which git site you want to push to).

like image 915
Tyler Rinker Avatar asked Feb 16 '13 15:02

Tyler Rinker


People also ask

How do I link my RStudio project to GitHub?

In RStudio, start a new Project: File > New Project > Version Control > Git. In “Repository URL”, paste the URL of your new GitHub repository. It will be something like this https://github.com/jennybc/myrepo.git .


1 Answers

The only way you could create a repository on github directly from your computer, without having to create it with their website first, would be to create a remote branch directly from git on your system. This is possible on some git installation, but not on Github.

However, Github provides an API that allows to create the repository from the command line, via a call to curl for example. You will find information on how to do it in this answer (not tested) :

curl -u 'USER:PASS' https://api.github.com/user/repos -d '{"name":"REPO"}'
git remote add origin [email protected]:USER/REPO.git
git push origin master

But I don't think you will be able to do it directly from RStudio : you will need to put your project under version control, and then to execute the three commands provided in the answer in a shell.

like image 144
juba Avatar answered Sep 28 '22 08:09

juba