LibGit2Sharp get all commits since {Hash}

Is it possible to get all commits since a specified commit using LibGit2Sharp?

I’ve tried the following.. but it didn’t work:

  • Guidelines for hosting VisualStudio projects on github
  • How can Windows file and folder shortcuts be created via C#.NET code?
  • Sitecore serialized items with Git autocrlf
  • Keeping track of changes I make by copying project folders
  • How to deploy a C#, MVC4 application on Azure using Git
  • Does anyone know of a good C# API for Subversion?
  • using ( var repo = new Repository( repositoryDirectory ) )
    {
        //Create commit filter.
        var filter = new CommitFilter
        {
            SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Reverse,
            Since = repo.Refs
        };
    
        /*Not Working
        if (shaHashOfCommit.IsNotEmpty())
            filter.Since = shaHashOfCommit;
        */
    
        var commits = repo.Commits.QueryBy( filter );
    }
    

  • Get a CVS log/history similar to the “git log” command?
  • Interactive rebase after merging/other commits interleaving mine
  • How to block push to master branch on remote
  • How to manage laravel 4 on remote server
  • Git invert staging area
  • How do patches work in Git?
  • One Solution collect form web for “LibGit2Sharp get all commits since {Hash}”

    The code below should meet your expectations.

    using (var repo = new Repository(repositoryDirectory))
    {
        var c = repo.Lookup<Commit>(shaHashOfCommit);
    
        // Let's only consider the refs that lead to this commit...
        var refs = repo.Refs.ReachableFrom(new []{c});
    
       //...and create a filter that will retrieve all the commits...
        var cf = new CommitFilter
        {
            Since = refs,       // ...reachable from all those refs...
            Until = c           // ...until this commit is met
        };
    
        var cs = repo.Commits.QueryBy(cf);
    
        foreach (var co in cs)
        {
            Console.WriteLine("{0}: {1}", co.Id.ToString(7), co.MessageShort);
        }       
    }
    
    Git Baby is a git and github fan, let's start git clone.