小编yez*_*ior的帖子

如何使用 ssh 使用 nodegit 克隆 git 存储库

我正在尝试使用库 nodegit(0.2.4 版)和 ssh 从 node.js 中的 teamforge 服务器克隆 git 存储库。我们的服务器向用户请求身份验证,当我尝试仅使用克隆方法而不传递选项时,我收到错误消息:“回调无法初始化 SSH 凭据”。

我在文件 private.key 和 public.key 中有私钥和公钥。它们位于我在网络风暴中设置为工作目录的目录中,因此位置应该不是问题。

没有找到如何做的例子(也许我错过了),但下面的代码是我得到的最接近的:

'use strict';

var nodegit = require("nodegit"),
Clone = nodegit.Clone,
cred = nodegit.Cred;

var options = {
    remoteCallbacks: {
        credentials: function () {
            return cred.sshKeyNew('user', 'public.key', 'private.key', '');
        }
    }
};

Clone.clone("ssh://user@teamforgeserver.net/reponame", "localTmp", options)
  .then(function(repo) {
        var r = repo;
    },
    function(err){
        var e = err;
    }
);
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

TypeError: Object #<Object> has no method 'isFulfilled' at value
(c:\...\proj\node_modules\nodegit\node_modules\nodegit-promise\lib\core.js:36:15)
Run Code Online (Sandbox Code Playgroud)

你有什么提示可能是错误的或一般如何做吗?

git ssh node.js libgit2 nodegit

6
推荐指数
1
解决办法
8672
查看次数

标签 统计

git ×1

libgit2 ×1

node.js ×1

nodegit ×1

ssh ×1