Question

I've been running round in circles for days now, I'm trying to implement a "pull" command which I understand libgit2sharp doesn't implement directly. I understand that I have to fetch from the remote and then merge this. I came up with the following code:

this._repo = new Repository(workingDir);
Credentials credentials = new Credentials() {Username = this._username, Password = this._password};
Remote remote = this._repo.Network.Remotes["origin"];
FetchOptions fetchOptions = new FetchOptions();
fetchOptions.Credentials = credentials;
var branch = @"refs/heads/TestBranch:refs/remotes/origin/TestBranch";
this._repo.Network.Fetch(remote, new string[] { branch }, fetchOptions);
//this._repo.Fetch(this._repo.Head.Name);
//this._repo.Fetch(remote.Name, fetchOptions);
//this._repo.Network.Fetch(remote, fetchOptions);  //this._repo.Network.Remotes["origin"], new FetchOptions() { Credentials = new Credentials() { Password = this._password, Username = this._username }});

I've left in the comments to show all the other variations of Fetch I've tried- but no matter what I try I always get the same error:

An error was raised by libgit2. Category = NoMemory (User).

Out of memory

The only time I've managed to not get this error was when I didn't enter my credentials and I got a 401 return code.

This is using a remote BitBucket account over HTTPS, I found 1 similar problem with BitBucket to do with the username being in the remote entry however this was supposed to be fix and still didn't work when I removed the username anyway.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top