从RStudio回复Github [英] Repo from RStudio to Github

查看:91
本文介绍了从RStudio回复Github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢github和RStudio的工作流程。最近,我创建了一个项目模板,可以创建目录和脚本等,并且希望在本地创建并推送到github。

过去,我通过 https://创建了一个项目的回购协议github.com/ 在RStudio中使用版本控制来创建本地回购,然后转储所有已存在的文件。



这看起来很浪费时间。如何使用.Rproj文件将RStudio中已有的目录/ repo上载到github中,然后首先在创建shell回购https://github.com/



我认为这可以节省工作流程的时间。



我想我可以按照指示 -here- (在将版本控制添加到项目)来添加版本控制,但这不允许我推送到github(也不应该这样,因为RStudio如何知道您要推送哪个git站点)。

解决方案

你可以直接从你的计算机上直接在github上创建一个仓库,而无需先用他们的网站创建仓库的唯一方法是直接从你系统上的git创建一个远程分支。这在一些git安装上是可能的,但不在Github上。



然而,Github提供了一个API,允许通过命令行创建存储库,例如code> curl 。您可以在此答案(未经测试)中找到有关如何操作的信息:

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

但我认为你不能直接从RStudio中完成它:你需要将你的项目放在版本控制之下,然后在shell中执行答案中提供的三个命令。 p>

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).

解决方案

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 git@github.com: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.

这篇关于从RStudio回复Github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆