0

我在网络 Web 服务器上有一个存储库:

http://rene:9095/git/TestGit.git

当我尝试从 C# 代码中打开它时,libgit2sharp会引发以下异常:

**Excepcion:** Path 'http://rene:9095/git/TestGit.git' doesn't point at a valid Git repository or workdir.
**InnerException:**  

我使用的代码导致Exception

Repository repo = new Repository(
  "http://rene:9095/git/TestGit.git", 
  new RepositoryOptions()
);

该存储库适用于 SourceTree 或 TortoiseGIT,但不适用于代码。我已经使用 Repository.Clone() 克隆了它并且工作正常。

你知道为什么存储库会抛出无效的代表吗?

提前谢谢!!

尼科。

4

1 回答 1

2

根据文档,构造函数似乎需要一个本地存储库,因此您提供的路径应该指向您的文件系统。

我想你会想要调用静态方法Repository.Clone(),因为它有签名string sourceUrl, string workdirPath, [..]。它返回克隆存储库的字符串路径,因此您可以这样编写:

var repoUrl = "http://repository-url";
var workingDir = @"C:\git\ProjectName\";
var repo = new Repository(Repository.Clone(repoUrl, workingDir));
于 2013-11-06T22:26:15.513 回答