如何使用 git2r 通过 ssh 推送 git 存储库? [英] How to push git repository through ssh using git2r?
问题描述
我正在尝试使用 git2r
包(版本 0.21.0).
我总是在我的项目中使用 ssh
连接(GitHub 和 GitLab 托管):我可以使用 RStudio IDE
和命令行执行 git pull/push
.
我有一个标准的 Ubuntu Xenial 配置;我的密钥以标准名称存储在 ~/.ssh
中,我的 ssh-agent
正在运行,并且密钥已添加到 ssh-agent
.我的问题是如何使用 git2r
包用 ssh
推送?
这是我用一个非常基本的工作流程做的事情(在 master
上工作,远程名称是 origin
):
库(git2r)回购 <- init("path_to_clone")远程网址(回购)
<块引用>
[1] "git@gitlab.com:account/repository.git"
credentials <- cred_ssh_key()str(凭据)
<块引用>
正式类 'cred_ssh_key' [package "git2r"] 有 3 个插槽..@ publickey : chr "/home/user/.ssh/id_rsa.pub"..@ 私钥:chr "/home/user/.ssh/id_rsa"..@ 密码:chr(0)
# 一些工作,add(), commit()...推(回购,起源",参考/头/主",凭证=凭证)
<块引用>
.local(object, ...) 中的错误:git2r_push"中的错误:不支持的 URL 协议
ssh
协议是否在 git2r
包中实现?有什么我错过的吗?`
我确实错过了一些东西.但是,什么?
libgit2_features()
<块引用>
$threads[1] 错误$https[1] 错误$ssh[1] 错误
我终于找到了我错过的东西.我在安装 git2r
之前忘记安装 libssh2-1-dev
库.
类似的问题此处.
安装libssh2-1-dev
:
sudo apt-get install libssh2-1-dev
I'm trying to use git2r
package (version 0.21.0).
I always use ssh
connexions in my projects (GitHub and GitLab hosted): I can do git pull/push
with both RStudio IDE
and command line.
I have a standard Ubuntu Xenial configuration; my keys are stored in ~/.ssh
with standard names, my ssh-agent
is running, and keys were added to ssh-agent
. My problem is how to use the git2r
package to push with ssh
?
Here's what I do with a very basic workflow (work on master
, remote name is origin
):
library(git2r)
repo <- init("path_to_clone")
remote_url(repo)
[1] "git@gitlab.com:account/repository.git"
credentials <- cred_ssh_key()
str(credentials)
Formal class 'cred_ssh_key' [package "git2r"] with 3 slots ..@ publickey : chr "/home/user/.ssh/id_rsa.pub" ..@ privatekey: chr "/home/user/.ssh/id_rsa" ..@ passphrase: chr(0)
# some work, add(), commit()...
push(repo, "origin", "refs/heads/master", credentials = credentials)
Error in .local(object, ...) : Error in 'git2r_push': unsupported URL protocol
Is ssh
protocol implemented in git2r
package? Is there something I missed?`
Edit: I missed something, for sure. But, what?
libgit2_features()
$threads [1] FALSE $https [1] FALSE $ssh [1] FALSE
I finally found what I missed. I forgot to install libssh2-1-dev
library before installing git2r
.
A similar question here.
Install libssh2-1-dev
:
sudo apt-get install libssh2-1-dev
这篇关于如何使用 git2r 通过 ssh 推送 git 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!