AFAIK, Repository.Commits property return all commits reachable from current branch.
I would like to get all possible commits, regardless the branch. I am using the following command :
var commitsToRewrite = repository.Branches.SelectMany(x => x.Commits)
.GroupBy(x => x.Sha)
.Select(x => x.First())
.ToArray();
It is slow but it seems to work (maybe I missed some special cases that are not covered). Is this the right way to do ? Is there a more efficient, faster way ?
Maybe not your case, but in some rare cases i've found that only traversing all branches could skip some commits (may be cause of branch deletion). This piece of code seems to do a better job (hope so), and as a plus is faster and less memory intensive.
I tested this with ReactOS git repo having more than 85000 commits and 500Mb.