I would like to view all of the commits since the last time the user pushed from their machine.
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);
}
}
I got this code from another post, but I am not sure how to modify it to get the commits since the date of the last push.
You want the commits that are reachable from
c
, excluding the ones that are reachable from the remote commit.If you're talking about
master
, in a typical setup, the tracking branch for this will beremotes/origin/master
.refs/remotes/origin/master
will be updated when you push to the remotemaster
branch.So your
CommitFilter
should look like:Which is equivalent to
git log refs/remotes/origin/master..c
.