Clicking on a bitpack using libgit2sharp

I am trying to use libgit2sharp to click on my repo on a bitbucket. I am trying to do this:

repo.Network.Push(repo.Branches[branchName], pushOptions); 

Everything seems fine, no exceptions are thrown, and I get no errors in the callback, but when I check the bitpack, there are no my commits. Other methods work fine (i.e., I can create a new branch on the bitbucket, and then use libgit2sharp to extract and see that I now have such a branch locally). Is there something I can skip here?

edit:

I tried just to make a small trial program to see if I can make this work not go away. I don't know if my code will help, but here it is:

  class Program { static void Main(string[] args) { PushOptions options = new PushOptions(); Credentials creds = new Credentials(); creds.Username = "username"; creds.Password = "password"; options.Credentials = creds; options.OnPackBuilderProgress = Program.packBuilderProgressHandler; options.OnPushTransferProgress = Program.pushTransferProgressHandler; options.OnPushStatusError = Program.pushStatusErrorHandler; Repository repo = new Repository("E:/Ohad/Work/libgitTest"); repo.Network.Push(repo.Branches["origin/master"], options); Console.WriteLine("Press enter to close..."); Console.ReadLine(); } public static bool packBuilderProgressHandler(PackBuilderStage stage, int current, int total) { Console.Out.WriteLine("packBuilder => " + current + " / " + total); return true; } public static bool pushTransferProgressHandler(int current, int total, long bytes) { Console.Out.WriteLine("pushTransfer => " + current + " / " + total + " , " + bytes); return true; } public static void pushStatusErrorHandler(PushStatusError error) { Console.Out.WriteLine("error => " + error.Message); } } 

Just create a new repo on the bitpack and add the code above (changing the material that is hard-coded) and it should be reproducible. I just made a random change, added and made it, and then used the program to try to click on the bit bag. The result that I get from the above:

 pushTransfer => 0 / 0 , 12 pushTransfer => 0 / 0 , 32 Press enter to close... 

0/0 looks suspicious to me, but I don't know what I'm doing wrong = /. Thanks for any help!

edit 2: I just added this:

  repo.Branches.Update(repo.Head, delegate(BranchUpdater updater) { updater.Remote = "origin"; updater.UpstreamBranch= repo.Head.CanonicalName; }) 

before that, when I click, and he fixed the problem. Not sure exactly why, but I'll take that =).

+2
source share
1 answer

I think that you are ready to click on the local master branch, and not on the remote tracking.

 repo.Network.Push(repo.Branches["master"], options); 

Update:

* The branch "master" ("refs / heads / master") that you are trying to click does not track the branch upstream. *

If you do not have an empty source, do the following:

 Remote remote = localRepo.Network.Remotes.Add("origin", url); repo.Branches.Update(repo.Head, -> (A) b => b.Remote = remote.Name, -> (B) b => b.UpstreamBranch = repo.Head.CanonicalName); -> (C) 

The code above should read as "The branch that HEAD (A) points to in this local repository is configured by default to track the branch with the same name (C) in the remote repository identified by this remote (B) ."

+3
source

All Articles