8

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.

Xaero Degreaz
  • 1,045
  • 11
  • 18
  • This would be much better asked on http://github.com/libgit2/libgit2sharp - it's a very active community. But to answer your question, merge is in progress. I'd be happy to discuss more on github... – Edward Thomson Feb 06 '13 at 19:50
  • 1
    I know it's active there, but I asked a question in the issue tracker, and was directed to ask here, so I have been :) – Xaero Degreaz Feb 06 '13 at 20:00
  • 2
    @EdwardThomson: Well, according to the **[README](https://github.com/libgit2/libgit2sharp/blob/vNext/README.md)**: *"Usage or programming related question? Post it on StackOverflow using the tag libgit2sharp"* ;-) – nulltoken Feb 06 '13 at 22:16
  • @nulltoken Thanks for the backup :-) Any idea how long we're talking about for merge implementation? I was using your GitSharp first, and it seems a bit more complete than LibGit2Sharp (I'm pretty sure merge was implemented). – Xaero Degreaz Feb 07 '13 at 02:03
  • *"Any idea how long we're talking about for merge implementation?"* -> Nope. I'll update the answer when it's ready. – nulltoken Feb 07 '13 at 09:04

2 Answers2

12

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.

Michael Minton
  • 4,447
  • 2
  • 19
  • 31
  • Network no longer has a Pull operation as of version 0.25.0 ... there is a new static Commands object with a Pull function however. – Nathan Tregillus May 23 '18 at 19:13
  • See my answer here for 2022/23 versions: https://stackoverflow.com/questions/36062476/libgit2sharp-replace-the-git-pull-command/75294195#75294195 – Rogério Silva Jan 31 '23 at 08:04
7

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)

nulltoken
  • 64,429
  • 20
  • 138
  • 130