c# - Libgit2Sharp : Get files associated with the initial (first) commit

标签 c# git libgit2 libgit2sharp

如何检索属于存储库第一次(初始)提交的文件?

我目前正在使用以下方法找出属于提交一部分的文件(并且有效)。但是,由于该方法需要两个参数,我应该传递什么来获取第一次提交的文件?或者我需要使用另一种方法吗?

    repo.Diff.Compare<TreeChanges>(repo.Commits.ElementAt(i).Tree, repo.Commits.ElementAt(i + 1).Tree)

谢谢!

最佳答案

您可以轻松地在初始树和空树之间进行比较以捕获文件:

foreach (TreeEntryChanges change in repo.Diff.Compare<TreeChanges>(null, commit.Tree))
{
     Console.WriteLine("\t{0} :\t{1}", change.Status, change.Path);
}

关于c# - Libgit2Sharp : Get files associated with the initial (first) commit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41600824/

相关文章:

c# - Windows 服务的后台 worker

c# - 在 SQL Server 上执行分页的最佳方法是什么?

git - TeamCity 代理错误 “failed to perform checkout on agent. exit code: 128”

java - SSH认证失败: Java JSCH

git - git diff origin master 应该做什么?

c# - 如何限制用户登录?

c# - 调用 WebRequest 以调用 Web 服务的非常简单的调用就是每次以某种方式进行两次调用,一个没有凭据,一个有?

c - 如何检索所有对象 ID?

.net - 哪种格式应该是 LibGit2 LibGit2Sharp (+SSH) 的 SSH 私钥

python - Repository.walk是否遍历所有提交