Search code examples
githubgit-fork

How to determine which forks on GitHub are ahead?


Sometimes, the original GitHub repository of a piece of software I'm using, such as linkchecker, is seeing little or no development, while a lot of forks have been created (in this case: 142, at the time of writing).

For each fork, I'd like to know:

  • which branches it has with commits ahead of the original master branch

and for each such branch:

  • how many commits it is ahead of the original
  • how many commits it is behind

GitHub has a web interface for comparing forks, but I don't want to do this manually for each fork, I just want a CSV file with the results for all forks. How can this be scripted? The GitHub API can list the forks, but I can't see how to compare forks with it. Cloning every fork in turn and doing the comparison locally seems a bit crude.


Solution

  • useful-forks

    useful-forks is an online tool which filters all the forks based on ahead criteria. I think it answers your needs quite well. :)

    For the repo in your question, you could do: https://useful-forks.github.io/?repo=wummel/linkchecker

    That should provide you with similar results to (ran on 2022-04-02): website

    Also available as a Chrome Extension

    Download it here: https://chrome.google.com/webstore/detail/useful-forks/aflbdmaojedofngiigjpnlabhginodbf

    Useful button

    And as a bookmarklet

    Add this as the URL of a new bookmark, and click that bookmark when you're on a repo:

    javascript:!function(){if(m=window.location.href.match(/github\.com\/([\w.-]+)\/([\w.-]+)/),m){window.open(`https://useful-forks.github.io/?repo=${m[1]}/${m[2]}`)}else window.alert("Not a GitHub repo")}();
    

    Although to be honest, it's a better option to simply get the Chrome Extension, if you can.

    Disclaimer

    I am the maintainer of this project.