不能通过节点child_process.spawn调用`git submodule add`

我所要做的就是执行cmd git submodule -q add -f --depth 1 https://github.com/user/repo node_modules/repo通过节点,但我似乎无法得到它的工作。

 var cmd = [ 'git', [ 'submodule', '--quiet', 'add', '--force', '--depth', '1', (self.url.replace('git+', '')), self.installTo ] ] var git = spawn.apply(spawn, cmd) git.stderr.on('data', log.error) git.on('close', function (code, signal) { // irrelevant because it errors out... } 

我在terminal中出现以下错误:

 ERR! usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>] or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...] or: git submodule [--quiet] init [--] [<path>...] or: git submodule [--quiet] deinit [-f|--force] [--] <path>... or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--reference <repository>] [--recursive] [--] [<path>...] or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...] or: git submodule [--quiet] foreach [--recursive] <command> or: git submodule [--quiet] sync [--recursive] [--] [<path>...] 

用法消息没有提及–depth。

这意味着所使用的git版本不够包含该选项。
它必须是1.8.4(2013年8月)之前的git:该选项由Fredrik Gustafsson( iveqy )的 提交275cd18添加,