在Windows 2012 R2上使用child_process / Spawn运行Git Pull时权限被拒绝

问题描述

我使用these instructions创建了一个ssh密钥,然后能够在Windows Server 2012 R2上使用命令提示符或git bash成功git pull进行加密。但是,尝试生成child_process并运行git pull时,出现以下错误

Host key verification Failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这是我的代码

    var child = spawn("git",["pull"],{
        cwd: "`C:\\path\\to\\repo"
    });

    child.on('error',function (err) {
        console.log(err);
    });

    child.stdout.on('data',function (data) {
        console.log(data);
    });

    child.stderr.on('data',function (data) {
        console.log(data);
    });

如果将命令更改为spawn("git",["checkout","master"],...,则会得到Already on 'master',因此我知道cwd的设置正确。

我正在使用git version 2.16.2.windows.1

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)