如何使用 LibGit2Sharp 从 fetch 中获取远程更改列表
How to get a list of remote changes from fetch using LibGit2Sharp
我能够使用 LibGit2Sharp 成功获取、拉取、推送等,但我希望能够在获取后列出已更改、添加等的文件。我正在使用 https://github.com/libgit2/libgit2sharp/wiki/git-fetch,没有发生任何错误或异常,并且 logMessage 是一个空字符串。
我希望能够像 Visual Studio 那样在您执行抓取时显示更改列表。
如何使用 LibGit2Sharp 来完成此操作?
编辑:
我已经通读了 LibGit2Sharp Wiki 和 LibGit2Sharp Hitchhiker's Guide to Git。虽然我已经尝试了一些可用的命令来查看它们提供的结果,但我也不确定等效的 git 命令是什么。如果您熟悉 Git 但不熟悉 LibGit2Sharp.
,了解和理解哪个命令会提供此信息将很有帮助,我们将不胜感激
获取完成后,您可以使用
列出给定分支的获取提交
git log ..@{u}
with @{u}
指定要合并的分支(上游远程跟踪分支,通常origin/yourbranch
)
在 LibGitSharp 中,这就是 LibGit2Sharp/BranchUpdater.cs#UpstreamBranch 参考(上游分支)
这样,您应该能够列出当前分支 HEAD 和“UpstreamBranch
”之间的提交,有点像 issue 1161,但该问题列出了正在推送的内容:让我们在这里反转日志参数。
var trackingBranch = repo.Head.TrackedBranch;
var log = repo.Commits.QueryBy(new CommitFilter
{ IncludeReachableFrom = trackingBranch.Tip.Id, ExcludeReachableFrom = repo.Head.Tip.Id });
var count = log.Count();//Counts the number of log entries
//iterate the commits that represent the difference between your last
//push to the remote branch and latest commits
foreach (var commit in log)
{
Console.WriteLine(commit.Message);
}
我能够使用 LibGit2Sharp 成功获取、拉取、推送等,但我希望能够在获取后列出已更改、添加等的文件。我正在使用 https://github.com/libgit2/libgit2sharp/wiki/git-fetch,没有发生任何错误或异常,并且 logMessage 是一个空字符串。
我希望能够像 Visual Studio 那样在您执行抓取时显示更改列表。
如何使用 LibGit2Sharp 来完成此操作?
编辑: 我已经通读了 LibGit2Sharp Wiki 和 LibGit2Sharp Hitchhiker's Guide to Git。虽然我已经尝试了一些可用的命令来查看它们提供的结果,但我也不确定等效的 git 命令是什么。如果您熟悉 Git 但不熟悉 LibGit2Sharp.
,了解和理解哪个命令会提供此信息将很有帮助,我们将不胜感激获取完成后,您可以使用
列出给定分支的获取提交git log ..@{u}
with @{u}
指定要合并的分支(上游远程跟踪分支,通常origin/yourbranch
)
在 LibGitSharp 中,这就是 LibGit2Sharp/BranchUpdater.cs#UpstreamBranch 参考(上游分支)
这样,您应该能够列出当前分支 HEAD 和“UpstreamBranch
”之间的提交,有点像 issue 1161,但该问题列出了正在推送的内容:让我们在这里反转日志参数。
var trackingBranch = repo.Head.TrackedBranch;
var log = repo.Commits.QueryBy(new CommitFilter
{ IncludeReachableFrom = trackingBranch.Tip.Id, ExcludeReachableFrom = repo.Head.Tip.Id });
var count = log.Count();//Counts the number of log entries
//iterate the commits that represent the difference between your last
//push to the remote branch and latest commits
foreach (var commit in log)
{
Console.WriteLine(commit.Message);
}