问题
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
回答1:
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
来源:https://stackoverflow.com/questions/48599858/how-to-push-git-repository-through-ssh-using-git2r