问题
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 readyMerge
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