What is the LibGit2Sharp equivalent of 'git pull'?

冷暖自知 提交于 2020-02-23 09:26:52

问题


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.


回答1:


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)




回答2:


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.



来源:https://stackoverflow.com/questions/14737441/what-is-the-libgit2sharp-equivalent-of-git-pull

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!