Go to First Commit on GitHub

I source a bunch of ideas from GitHub. These repositories help me understand how to implement functionality without rifling through pages of documentation, validate if a particular npm package I want to install is worth its weight in gold (or is bogged down with countless issues and unresolved pull requests), and keep up to date on research proposals and development on popular codebases.

But I’ve always found it difficult to navigate to the first commit. I do this for several reasons, whether I need to judge the age of the software — which I can also trivially do by checking the commit date of the README.MD or LICENSE, but is sometimes inaccurate. Or I’m curious, and I want to see how the project grew from the first sown seed. Barring quickly looking at the number of stars and forks of a project, I would hope that Github adds a label that can indicate when the project’s first lines of code were written.

Now, power users can click on the total number of commits on the homepage of a repository and go to the last page by simply editing the number after the SHA in the URL. An example:

TrumpTracker has 330 commits at the time of writing. The URL for the repo is —

https://github.com/TrumpTracker/trumptracker.github.io/commits/master?after=7d27f3b4278ad9a8f1282e0cc7dad53e9bf11c77+300&branch=master

Where the bolded 300 should be the

total # of commits - 30 === 330 - 30 = 300

And the constant 30 is the arbitrary number of commits they show per page.

One can perform these calculations and brute force render the last page, but I have a better, more sophisticated solution.

Add this piece of code as a bookmarklet, go to any Github repository and click it.

javascript:(b%3D>fetch(%27https://api.github.com/repos/%27%2Bb%5B1%5D%2B%27/commits%3Fsha%3D%27%2B(b%5B2%5D%7C%7C%27%27)).then(c%3D>Promise.all(%5Bc.headers.get(%27link%27),c.json()%5D)).then(c%3D>%7Bif(c%5B0%5D)%7Bvar d%3Dc%5B0%5D.split(%27,%27)%5B1%5D.split(%27%3B%27)%5B0%5D.slice(2,-1)%3Breturn fetch(d).then(e%3D>e.json())%7Dreturn c%5B1%5D%7D).then(c%3D>c.pop().html_url).then(c%3D>window.location%3Dc))(window.location.pathname.match(/%5C/(%5B%5E%5C/%5D%2B%5C/%5B%5E%5C/%5D%2B)(%3F:%5C/tree%5C/(%5B%5E%5C/%5D%2B))%3F/))%3B

I recommend bookmarking any site (such as this one) and then editing the bookmark by right-clicking it. I’ve set it up in a similar fashion.

I can’t for the life of me remember where I sourced this code, but if anyone has any leads, I’ll be sure to credit the author. :)