0

I have a repository on a network web server:

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

When I try to open it from C# code with libgit2sharp it throws the following exception:

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

The code I use and which causes the Exception:

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

The repository works fine with SourceTree or TortoiseGIT but not with the code. I've Cloned it using Repository.Clone() and works fine too.

Do you have any idea why the repository throws invalid rep?

Thanks in advnace!!

Nico.

9000
  • 39,899
  • 9
  • 66
  • 104

1 Answers1

2

According to the documentation, the constructor seems to expect a local repository, so the path you supply should point to your filesystem.

I think you'll want to call the static method Repository.Clone(), as it has the signature string sourceUrl, string workdirPath, [..]. It returns a string path to the cloned repository, so you can write it like:

var repoUrl = "http://repository-url";
var workingDir = @"C:\git\ProjectName\";
var repo = new Repository(Repository.Clone(repoUrl, workingDir));
CodeCaster
  • 147,647
  • 23
  • 218
  • 272