Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

git log

Chris Hamons edited this page Apr 13, 2015 · 11 revisions

git-log

Show HEAD commit logs

Limiting the number of commits to show

Git

$ git log -15

LibGit2Sharp

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();
    }
}

Changing the order of the commits

Git

$ git log --topo-order --reverse

LibGit2Sharp

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 ;-)
    }
}

Show only commits between two named commits

Git

$ git log master..development

LibGit2Sharp

using (var repo = new Repository("path/to/your/repo"))
{
    var filter = new CommitFilter { Since = repo.Branches["master"], Until = repo.Branches["development"] };

    foreach (Commit c in repo.Commits.QueryBy(filter))
    {
        Console.WriteLine(c.Id);   // Of course the output can be prettified ;-)
    }
}

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.