【问题标题】:How to push git repository through ssh using git2r?如何使用 git2r 通过 ssh 推送 git 存储库?
【发布时间】:2018-02-03 17:10:30
【问题描述】:

我正在尝试使用 git2r 包(版本 0.21.0)。
我总是在我的项目(GitHub 和 GitLab 托管)中使用 ssh 连接:我可以使用 RStudio IDE 和命令行来执行 git pull/push
我有一个标准的 Ubuntu Xenial 配置;我的密钥以标准名称存储在~/.ssh 中,我的ssh-agent 正在运行,并且密钥已添加到ssh-agent。我的问题是如何使用git2r包与ssh一起推送?

这是我对一个非常基本的工作流程所做的(在 master 上工作,远程名称是 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 

ssh 协议是否在 git2r 包中实现?有什么我错过的吗?`


编辑:我确实错过了一些东西。但是,什么?

libgit2_features()
$threads
[1] FALSE
$https
[1] FALSE
$ssh
[1] FALSE

【问题讨论】:

    标签: r git ssh libgit2


    【解决方案1】:

    我终于找到了我错过的东西。在安装 git2r 之前我忘记安装 libssh2-1-dev 库。
    类似的问题here

    安装libssh2-1-dev

    sudo apt-get install libssh2-1-dev
    

    【讨论】:

    • 好收获。我错误地认为这是一个 URL 问题。 +1
    猜你喜欢
    • 2013-05-16
    • 2019-06-09
    • 1970-01-01
    • 2015-04-21
    • 2021-03-05
    • 2023-04-06
    • 2013-07-22
    • 1970-01-01
    • 2011-05-12
    相关资源
    最近更新 更多