Question

Is there a way to use LibGit2Sharp to get a list of the files in a remote repository, but without cloning the repository locally?

I'd like to list the files, but also get the content of the files.

var files = GetGithubFiles(); // TODO: Implement
foreach(var file in files)
{
    Console.WriteLine(file.Title);
    Console.WriteLine(file.Content);
    Console.WriteLine();
}
Was it helpful?

Solution

Is there a way to use LibGit2Sharp to get a list of the files in a remote repository, but without cloning the repository locally?

There's no currently built-in mechanism to perform such task.

Beside retrieving the list of files of the commits of each heads of the repository, cloning fetches the whole history. This may indeed take some time.

However, below some alternative to help you forward:

  • Leverage now the GitHub API
  • Wait for the future support of shallow clones, which should allow you to retrieve a shorter version of the history, perform your analysis and eventually discard the temporary repository.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top