3

nodegitを使用して、次のコードで git リポジトリを開こうとしています。

var git = require('nodegit');

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

repoPathこれにより、変数に何を割り当てても、次のエラーが発生します。

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

ローカル フォルダーへのパスを試しました。フォルダーを含むローカル フォルダーへのパスを.git試しました。URL を使用してリモート リポジトリを試しました。いいえ、別に。

誰でも助けてもらえますか?


ノード v0.10.24 nodegit v0.1.4を使用しています

git 1.9.0.msysgit.0
勝利 8.1 プロ 64 ビット

4

1 に答える 1

5

openメソッドを使用してリポジトリを開く必要があります。

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

git はローカルで動作するため、リモート パスの使用は機能しません。クローンを作成したい場合はclone、クローンが実行された後に関数を呼び出すメソッドも利用できます。

git = require('nodegit')
git.Repo.clone('git://some-host/path', 'local-path', null, function(err, repo) {
  console.log(repo.path())
}
于 2014-09-02T09:53:19.367 に答える