标签: libgit2sharp

3
推荐指数
1
解决办法
691
查看次数

LibGit2Sharp CheckoutPaths()

我做了一个提交(49916 .....)现在我想将一个提交文件签出到工作目录中.该文件名为NEW.txt.如果我输入

Git checkout 49916 NEW.txt

进入Git Bash它会创建带有我工作目录内容的NEW.txt文件.

但我的LibGit2Sharp命令不想工作.我究竟做错了什么?

       var repo = new Repository(repopath);
       var checkoutPaths = new[] { "NEW.txt"};    
       repo.CheckoutPaths("49916", checkoutPaths);
Run Code Online (Sandbox Code Playgroud)

我读了每篇关于checkoutpaths函数的文章.但是我无法让它发挥作用.我从LibGit2Sharp结帐测试文件中获取了该函数.

            repo.CheckoutPaths(checkoutFrom, new[] { path });
Run Code Online (Sandbox Code Playgroud)

git repository git-checkout libgit2 libgit2sharp

3
推荐指数
1
解决办法
855
查看次数

使用libgit2sharp从远程存储库获取更新

我需要我的应用程序用Git做两个简单的操作.
1)克隆远程存储库;
2)定期从远程存储库执行更新.

我绝对不知道如何用libgit2sharp做到这一点.API非常复杂.

有人能帮帮我吗?

libgit2sharp

3
推荐指数
1
解决办法
3111
查看次数

使用libgit2sharp克隆和推送

任何人都可以告诉我如何克隆回购并推送或发布已提交的更改?

目前我能够修改克隆存储库并能够提交我的更改,但我不喜欢api来推动它.也最初克隆回购.

如果它不可用,使用c#的替代方法是什么?

-Jaffer

c# github github-api libgit2 libgit2sharp

2
推荐指数
1
解决办法
3543
查看次数

如何在gitattributes中应用语言的diff规则

例如,该行的.gitattributes文件.代码的输出lg2s*.cs diff=csharp

using (var repo = new Repository(@"path\to\lg2s"))
{
    var tree1 = repo.Lookup<Commit>("a845db9").Tree;
    var tree2 = repo.Lookup<Commit>("d677741").Tree;
    var patches = repo.Diff.Compare<Patch>(tree1, tree2);
    foreach (var patch in patches)
    {
        Console.WriteLine(patch.Patch);
    }
}
Run Code Online (Sandbox Code Playgroud)

是(不久)

diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs
@@ -59,8 +59,8 @@ namespace LibGit2Sharp
Run Code Online (Sandbox Code Playgroud)

但输出git bash是(很快)

diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs
@@ -59,8 +59,8 @@ internal RepositoryStatus(Repository repo, StatusOptions optio
Run Code Online (Sandbox Code Playgroud)

第二行不一样.

看起来有一个深入的讨论Add .gitattributes support libgit2 /#508,但PR Add APIs for git attributes libgit2 /#516是否合并?

现在支持多少种语言? …

libgit2 libgit2sharp

2
推荐指数
1
解决办法
998
查看次数

C#如何使用libgit2Sharp读取提交时间

我试图使用libgit2Sharp列出存储库中的所有提交,其作者和提交日期,但提交对象没有创建提交的日期/时间属性.

 using (var repo = new Repository(path))
 {
     ///get commits from all branches, not just master
     var commits = repo.Commits.QueryBy(new CommitFilter { Since = repo.Refs });

     //here I can access commit's author, but not time
     commits.Select(com => new { Author = com.Author.Name, Date = com.???
  }
Run Code Online (Sandbox Code Playgroud)

我没有在官方页面上找到libgit2sharp项目的任何文档:

让我们简单地说:我们目前缺乏适当的文档.任何关于这个主题的帮助将不胜感激;-)

我怎样才能访问commit的时间?

c# git libgit2sharp

2
推荐指数
1
解决办法
1375
查看次数

如何通过 libgit2sharp 在本地克隆 GitHub 存储库?

我编写了代码,通过 libgit2sharp ( v0.21.0.176 ) 以编程方式将 GitHub 私有存储库克隆到本地存储库

var cloneOptions = new CloneOptions { BranchName = "master", Checkout = true };
var cloneResult = Repository.Clone( @"https://github.com/my-organization/my-repo.git", @"c:\github\my-organization\my-repo" );
Run Code Online (Sandbox Code Playgroud)

抛出异常:

{LibGit2Sharp.LibGit2SharpException: Request failed with status code: 401
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
Run Code Online (Sandbox Code Playgroud)

cloneResult 值为空(由于抛出异常而从未设置)

请注意,无论 \my-repo\ 文件夹是否存在,都会抛出相同的 401 异常。

我的函数调用语法正确吗?

从命令行执行,git clone首先创建要克隆到的本地 dir 文件夹。

libgit2sharp 的Repository.Clone()工作方式不同吗?

git github git-clone libgit2sharp

2
推荐指数
1
解决办法
2108
查看次数

如何使用libgit2sharp更改/删除/添加文件?

我有两个约会 - 从和到.我必须在日期差异之间找到存储库中更改的文件并列出它.这是一个相关的问题,它可以得到树之间的差异.从LibGit2Sharp中的提交中获取已修改/添加/删除的文件.

c# git libgit2 libgit2sharp

2
推荐指数
1
解决办法
1741
查看次数

您如何使用LibGit2Sharp向VSTS进行身份验证?

我正在尝试使用LibGit2Sharp克隆VSTS(Visual Studio Team Services)存储库。我正在设置CredentialsHandlerUsernamePasswordCredentials代表我的Microsoft帐户的凭据,得到的结果是:

LibGit2Sharp.LibGit2SharpException was unhandled
  HResult=-2146233088
  Message=Too many redirects or authentication replays
  Source=LibGit2Sharp
Run Code Online (Sandbox Code Playgroud)

如果我什至无法传递我的真实用户名和密码,我不确定是否可行。

我也尝试过使用这里DefaultCredentials提到的方法,但这似乎仅用于TFS,而不是VSTS(用于TFS的NTLM凭据)。

git tfs libgit2sharp azure-devops

2
推荐指数
1
解决办法
1385
查看次数

libgit2sharp - Git - 无法推送非快进引用

libgit2sharp生成文件后,我正在使用它们将文件推送到存储库。

using (var repo = new Repository(RepositoryPath))
{
    // Stage the file
    Commands.Stage(repo, "*");

    // Create the committer's signature and commit
    Signature author = new Signature("translator", "example.com", DateTime.Now);
    Signature committer = author;

    // Commit to the repository
    Commit commit = repo.Commit($"Resx files updated {DateTime.Now}", author, committer);

    Remote remote = repo.Network.Remotes["origin"];
    var options = new PushOptions
    {
        CredentialsProvider = (_url, _user, _cred) =>
           new UsernamePasswordCredentials
           {
               Username = _settings.GitUserName,
               Password = _settings.GitPassword
           }
     };
     repo.Network.Push(remote, @"refs/heads/master", options);
 } 
Run Code Online (Sandbox Code Playgroud)

这已经有一段时间了,并且没有问题地推送到存储库,但是我现在收到某些文件的以下错误消息,并且没有发生任何文件的推送。

错误消息(来自服务器日志): …

c# git libgit2 libgit2sharp

2
推荐指数
1
解决办法
5070
查看次数