What is the LibGit2Sharp equivalent of 'git pu

2019-06-17 09:51发布

I'm trying to merge changes from the remote branch into the local repository, however I've been unable to get this to work properly -- likely misunderstanding of the implementation. Fetching seems to work fine, as I can see the updates on the server, but I think I'm breaking something when attempting to pull.

I've tried:

repo.Checkout( branch.TrackedBranch, CheckoutOptions.None, OnCheckoutProgress );

This seems to do what you would expect from a Clone call. I can also not find a method to merge. As I've read, git pull is just like calling a fetch, then a merge.

I've looked at some of the tests in the repo, such as the MergeFixture, but it didn't seem to be what I was hoping it would be.

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-06-17 10:14

Pull is indeed the combination of Fetch and Merge.

  • Fetch is ready
  • Merge is in progress (as stated by @EdwardThomson)

I've looked at some of the tests in the repo, such as the MergeFixture, but it didn't seem to be what I was hoping it would be.

As the complete merge process isn't available yet, there aren't many tests yet. However, MergeFixture.cs includes some aspects of the merge

  • Detection of conflicts/unmerged entries
  • Retrieval of the branch(es) being merged

There are other related bits in the CommitFixture.cs as well

  • Cleanup of potential merge metadata on Commit
  • Automatic inclusion of parents when issue a merge Commit

Libgit2 also includes some lower level bits to deal with conflicts that have been resolved by the user.

Update

Merge feature is now available in LibGit2Sharp (see pull request #608)

查看更多
家丑人穷心不美
3楼-- · 2019-06-17 10:25

Update as of April 2014

A convenience method of Pull has been added to LibGit2Sharp.

repo.Network.Pull(signature, pullOptions);

You can find more basic usages in the test fixtures.

查看更多
登录 后发表回答