Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the LibGit2Sharp equivalent of 'git pull'?

Tags:

libgit2sharp

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.

like image 476
Xaero Degreaz Avatar asked Feb 06 '13 19:02

Xaero Degreaz


People also ask

Is pull request same as git pull?

The git pull command is used to pull a repository. Pull request is a process for a developer to notify team members that they have completed a feature. Once their feature branch is ready, the developer files a pull request via their remote server account.

What is git pull short for?

In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD . More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase , it runs git rebase instead of git merge.

Is git pull a fetch and merge?

The git pull command is actually a combination of two other commands, git fetch followed by git merge . In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. Once the content is downloaded, git pull will enter a merge workflow.

What is git pull only?

git pull is a Git command used to update the local version of a repository from a remote. It is one of the four commands that prompts network interaction by Git. By default, git pull does two things. Updates the current local working branch (currently checked out branch)


2 Answers

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.

like image 54
Michael Minton Avatar answered Sep 19 '22 14:09

Michael Minton


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)

like image 26
nulltoken Avatar answered Sep 19 '22 14:09

nulltoken