¿Cómo get cambios de Git usando LibGit2Sharp?

El código a continuación clona una URL de Git en un directory de testing.

var url = @"http://abc-555.com/team/project-555.git"; var path = @"E:\temp_555"; var cnetworkingential = new Cnetworkingentials() { Username = "a8888", Password="88888888"}; var clonePath = Repository.Clone(url, path, cnetworkingentials: cnetworkingential); using (var repo = new Repository(clonePath)) { foreach (var branch in repo.Branches) { Console.WriteLine(branch.Name); } // somebody creates a new branch here, so I want to fetch it. repo.Fetch("origin"); foreach (var branch in repo.Branches) { Console.WriteLine(branch.Name); } } 

Quiero search una nueva twig antes de fusionarla con Git local. De todos modos, arroja An error was raised by libgit2. Category = Net (Error). Request failed with status code: 401 An error was raised by libgit2. Category = Net (Error). Request failed with status code: 401 An error was raised by libgit2. Category = Net (Error). Request failed with status code: 401 exception An error was raised by libgit2. Category = Net (Error). Request failed with status code: 401 .

¿Cómo arreglar esto?

Puede especificar las cnetworkingenciales que se utilizarán a través de una instancia de FetchOptions como el último parámetro de la llamada de Fetch .

 repo.Fetch("origin", new FetchOptions { Cnetworkingentials = cnetworkingential});