windows Libgit2sharp带有progressbar的克隆仓库

hyrbngr7  于 2023-05-08  发布在  Windows
关注(0)|答案(1)|浏览(116)

有没有人可以指导我如何从公共URL中克隆超过1GB的Git存储库
克隆时
Repository.clone(“url”);

gk7wooem

gk7wooem1#

下面是一个例子:

using LibGit2Sharp.Handlers;
using LibGit2Sharp;

// Define source/dest
var source = "https://github.com/org/blah.git";
var dest = "c:\\temp\\blah\\";

// Clone fails if destination already exists
if (Directory.Exists(dest))
{
    Console.WriteLine("Directory exists and is not an empty directory, please fix and try again.");
    Environment.Exit(0);
}

// Create a delegate to handle progress events
var gitProgress = new ProgressHandler((serverProgressOutput) =>
{
    // Print output to console
    Console.Write(serverProgressOutput);

    // Move cursor to beginning of line
    (int left, int top) = Console.GetCursorPosition();
    Console.SetCursorPosition(0,top);

    return true;
});

// Clone repo using progress handler
var x = Repository.Clone(source, dest, new CloneOptions { OnProgress = gitProgress });

相关问题