Retrieving list of files with last commits


I must be missing something obvious, because GitHub web interface does that on the Code tab.

I am looking for an API call that would either give me list of files with reference to the last commit that they were modified with, or, list of commits with files they modified. (If it is of any relevance, the repo I am dealing with at the moment has over 4000 tiny files, and each commit modifies one file only.)

Using Octokit, I can get list of all files using GitHubClient.Repository.Content.GetAllContents, or using GitHubClient.Git.Tree.GetRecursive, and I can get list of all commits using GitHubClient.Repository.Commit.GetAll, but there seems to be absolutely nothing in the responses that would link the two together.

There is an API for a single commit details that lists the modified files, but I would have to make an API call it for each commit separately.

Is there a way to get the list of files and last associated commit with them the way it is shown on the website when browsing code?


like what? on GitHub Web, when you click Commits, just like this?

in my understanding of your description, you want to see all the files with latest commits, not just like that,

Like the listing on the Code tab:


path string query
Only commits containing this file path will be returned.

Repeated for each file in the directory.

Thank you @jsoref, but I would spend the API requests limit only doing that for the thousands of files, not mentioning how long that would take. Is there no better way?

as for me, I’ve also look at all possible endpoints but the list commits is the closest one, automate each commit to see what file has the commit, get the latest one for each, and you will have the view just like the Code tab you mentioned,

Clone the repository.

That API is the equivalent of:

git log [ref] -- [path]