通过Lib2GitSharp进行Git Checkout和Pull [英] Git Checkout and Pull through Lib2GitSharp

查看:776
本文介绍了通过Lib2GitSharp进行Git Checkout和Pull的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建一个应用程序,它定期扫描各个Git分支上的提交历史记录,并报告作者和有关提交消息的各种详细信息。为此,我已开始使用 LibGit2Sharp 。它非常适合自己访问提交,但在尝试更新存储库时遇到了一些问题。

I am trying to build an application that periodically scans the commit history on various Git branches and reports on the authors and various details about the commit messages. I have started using LibGit2Sharp for this. It has been great for accessing the commits themselves, but I have run into a snag when trying to update the repository.

每当我的任务运行时,我都需要获取来自远程存储库的最新更改。我的理解是我需要签出追踪有问题的远程分支的本地分支,然后执行提取或拉取。我尝试在我的应用程序中执行此操作,如下所示:

Every time my task runs, I need to get the most recent changes from the remote repository. My understanding is I need to checkout the local branch that tracks the remote branch in question, then perform a fetch or pull. I am attempting to do this in my app as follows:

// Get the branch
var localBranch = repo.Branches[localbranchName];

// Switch to this branch
if (!localBranch.IsCurrentRepositoryHead)
{
    repo.Checkout(localBranch);
}

// Do a pull to get latest
var result = repo.Network.Pull(signature, new PullOptions());

但是,运行 repo.Checkout时总会得到以下异常(localBranch );

LibGit2Sharp.LibGit2SharpException: Failed to mmap. No data written: Not enough storage is available to process this command.
  at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 160
  at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 178
  at LibGit2Sharp.Core.Proxy.git_checkout_tree(RepositorySafeHandle repo, ObjectId treeId, GitCheckoutOpts& opts) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 295
  at LibGit2Sharp.Repository.CheckoutTree(Tree tree, IList`1 paths, IConvertableToGitCheckoutOpts opts)...

当我手动在Git Bash中检出该分支并运行我的程序时(绕过了对checkout命令)然后在调用Pull时出现同样的异常。

When I manually checkout that branch in Git Bash and run my program (bypassing the need for the the checkout command) it then fails on the call to Pull with the same exception.

关于这个错误没有太多,但是迄今为止我看到的所有东西都导致了回答你的存储库太过分了的程度ge为图书馆处理。我使用的存储库是一个合理大小的企业存储库,但这些命令在控制台中很快就会执行。我想知道现在是否需要将我的控制台包装在处理程序中并执行结帐并直接通过CLI(yuck)进行提取。

There's not a whole lot about this error out there but everything I've seen so far has resulted in answers to the extent of "Your repository is just too large for the library to handle." The repository I am using is a fair-sized enterprise repository, but these commands execute in the console pretty quickly. I'm wondering now if I need to wrap my console in a handler and execute the checkout and pull directly through the CLI (yuck).

有什么想法?

推荐答案

对此抱歉。对libgit2和LibGit2Sharp进行了一些更改,以处理内存使用情况,并更好地处理内存映射,尤其是对于大型(或众多)的包文件。

Apologies for this. There have been a handful of changes to libgit2 and LibGit2Sharp to deal with memory usage, and better handling of memory mapping, especially with large (or numerous) packfiles.

请参阅下一版LibGit2Sharp中的这些改进。在此之前,从 nuget.org 安装预发布包应该可以解决此问题。

You will see these improvements in the next release of LibGit2Sharp. Until then, installing a prerelease package from nuget.org should resolve this issue.

这篇关于通过Lib2GitSharp进行Git Checkout和Pull的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆