【问题标题】:Can't Open Remote repository on network web server无法在网络 Web 服务器上打开远程存储库
【发布时间】:2013-11-06 21:48:17
【问题描述】:

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

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

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

**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() 克隆它并且工作正常。

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

提前感谢!!

尼科。

【问题讨论】:

    标签: c# git libgit2sharp


    【解决方案1】:

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

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

    var repoUrl = "http://repository-url";
    var workingDir = @"C:\git\ProjectName\";
    var repo = new Repository(Repository.Clone(repoUrl, workingDir));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-18
      • 2016-12-16
      • 2010-12-31
      • 1970-01-01
      • 2010-10-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多