-
Notifications
You must be signed in to change notification settings - Fork 889
git log
Colin Ng edited this page Dec 6, 2017
·
14 revisions
$ git log -15
using (var repo = new Repository("path/to/your/repo"))
{
var RFC2822Format = "ddd dd MMM HH:mm:ss yyyy K";
foreach (Commit c in repo.Commits.Take(15))
{
Console.WriteLine(string.Format("commit {0}", c.Id));
if (c.Parents.Count() > 1)
{
Console.WriteLine("Merge: {0}",
string.Join(" ", c.Parents.Select(p => p.Id.Sha.Substring(0, 7)).ToArray()));
}
Console.WriteLine(string.Format("Author: {0} <{1}>", c.Author.Name, c.Author.Email));
Console.WriteLine("Date: {0}", c.Author.When.ToString(RFC2822Format, CultureInfo.InvariantCulture));
Console.WriteLine();
Console.WriteLine(c.Message);
Console.WriteLine();
}
}
$ git log --topo-order --reverse
using (var repo = new Repository("path/to/your/repo"))
{
var filter = new CommitFilter { SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Reverse };
foreach (Commit c in repo.Commits.QueryBy(filter))
{
Console.WriteLine(c.Id); // Of course the output can be prettified ;-)
}
}
$ git log master..development
using (var repo = new Repository("path/to/your/repo"))
{
var filter = new CommitFilter {
ExcludeReachableFrom = repo.Branches["master"], // formerly "Since"
IncludeReachableFrom = repo.Branches["development"], // formerly "Until"
};
foreach (Commit c in repo.Commits.QueryBy(filter))
{
Console.WriteLine(c.Id); // Of course the output can be prettified ;-)
}
}
$ git log tag1 tag2
using (var repo = new Repository(@"path/to/your/repo"))
{
Tag tagTo = repo.Tags["tag2"];
Tag tagFrom = repo.Tags["tag1"];
var filter = new CommitFilter()
{
IncludeReachableFrom = tagTo.Target.Sha,
ExcludeReachableFrom = tagFrom.Target.Sha
};
var commits = repo.Commits.QueryBy(filter).ToList();
}
$ git log tag1 tag2 --stat
using (var repo = new Repository(@"path/to/your/repo"))
{
Tag tagTo = repo.Tags["tag2"];
Tag tagFrom = repo.Tags["tag1"];
var commitFrom = repo.Lookup<LibGit2Sharp.Commit>(tagFrom.Target.Sha);
var commitTo = repo.Lookup<LibGit2Sharp.Commit>(tagTo.Target.Sha);
TreeChanges treeChanges = repo.Diff.Compare<TreeChanges>(commitFrom.Tree, commitTo.Tree);
}