我问了一个related的问题,并意识到我没有提出正确的问题(即,这不是关于git)。通过curl命令行发送到github(Windows)
问题是如何在没有首先使用R在云中创建项目的情况下将项目推送到github。目前,您可以使用来自this question的信息从RStudio中的git命令行执行此操作。
现在我试图从Windows机器上将它变成R代码(Linux很容易)。我被困在第一步,通过R system
调用从命令行使用curl。我会显示我的内容,然后显示错误消息(Thanks to SimonO101 for getting me this far.)。按他的下面我的意见已经编辑很大程度上反映问题,因为它:
R代码里面:
repo <- "New"
user <- "trinker"
password <- "password"
url <- "http://curl.askapache.com/download/curl-7.23.1-win64-ssl-sspi.zip"
tmp <- tempfile(fileext = ".zip")
download.file(url,tmp)
unzip(tmp, exdir = tempdir())
system(paste0(tempdir(), "/curl http://curl.haxx.se/ca/cacert.pem -o " ,
tempdir() , "/curl-ca-bundle.crt"))
cmd1 <- paste0(tempdir(), "/curl -u '", user, ":", password,
"' https://api.github.com/user/repos -d '{\"name\":\"", repo, "\"}'")
system(cmd1)
cmd2 <- paste0(tempdir(), "/curl -k -u '", user, ":", password,
"' https://api.github.com/user/repos -d '{\"name\":\"", repo, "\"}'")
system(cmd2)
错误消息(同样为这两种方法):
> system(cmd1)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 12 0 0 100 12 0 24 --:--:-- --:--:-- --:--:-- 30
100 47 100 35 100 12 65 22 --:--:-- --:--:-- --:--:-- 83{
"message": "Bad credentials"
}
我知道所有文件都存在,因为:
> dir(tempdir())
[1] "curl-ca-bundle.crt" "curl.exe" "file1aec62fa980.zip" "file1aec758c1415.zip"
它不能是我的密码或用户名,因为这个工程在Linux Mint的(唯一的区别是卷曲之前的部分):
repo <- "New"
user <- "trinker"
password <- "password"
cmd1 <- paste0("curl -u '", user, ":", password,
"' https://api.github.com/user/repos -d '{\"name\":\"", repo, "\"}'")
system(cmd1)
注:Windows 7机器。 [R 2.14.1
这个呢,因为你建议在我的Mac上正常工作。错误提示您是否尝试过'-k'选项?即'cmd1 < - paste0(“curl -k -u'”,用户,“:”,密码, “'https://api.github.com/user/repos -d'{\”name \“: \“”,回购,“\”}'“)' – 2013-02-23 16:17:50
是的,它似乎无限期挂断。我会再试一次。 – 2013-02-23 16:18:18
啊,它也挂了,但我不小心关上了我的MBP盖子。当我重新打开它时,命令已经完成,并且回购已经出现在GitHub上!去搞清楚。 – 2013-02-23 16:19:25