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

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()克隆了它,也可以正常工作。

您是否知道为什么存储库会引发无效的代表?

感谢Advnace!

尼科。

有帮助吗?

解决方案

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

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

var repoUrl = "http://repository-url";
var workingDir = @"C:\git\ProjectName\";
var repo = new Repository(Repository.Clone(repoUrl, workingDir));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top