简体   繁体   English

无法使用NodeGit打开存储库

[英]Trouble opening repository with NodeGit

I'm trying to use nodegit to open up a git repository with the following code: 我正在尝试使用nodegit打开一个包含以下代码的git存储库:

var git = require('nodegit');

git.Repo(repoPath, function(error, repository) {
  if (error) throw error;
}

This gives me the following error, no matter what I assign the repoPath variable: 这给了我以下错误,无论我分配repoPath变量:

git.Repo(repoPath, function(error, repository) {
    ^
Error: git_repository is required.

I have tried path to local folder, I have tried path to local folder, including the .git folder, I have tried a remote repo using url. 我已经尝试过本地文件夹的路径,我已经尝试过本地文件夹的路径,包括.git文件夹,我尝试过使用url的远程仓库。 No nothing. 没什么。

Can anyone help out? 任何人都可以帮忙吗?

I'm using 我正在使用
node v0.10.24 节点v0.10.24
nodegit v0.1.4. nodegit v0.1.4。
git 1.9.0.msysgit.0 git 1.9.0.msysgit.0
win 8.1 pro 64bit 赢得8.1 pro 64bit

You need to use the open method to open the repository. 您需要使用open方法打开存储库。

git = require('nodegit')
git.Repo.open('some-path', function(err, repo) {
  console.log(repo.path())
}

Using a remote path won't work as git works locally. 使用远程路径不起作用,因为git在本地工作。 If you'd like to clone, there's a clone method available which will also call a function once the clone has been performed, like 如果你想克隆,可以使用一种clone方法,一旦克隆被执行,它也会调用一个函数,比如

git = require('nodegit')
git.Repo.clone('git://some-host/path', 'local-path', null, function(err, repo) {
  console.log(repo.path())
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM