Search code examples
githubgithub-api

How to check whether I have a fork of a given GitHub repo?


Let's say there is a repository foo/bar which I forked to me/custom-bar. How do I check programmatically (API call maybe?) given foo/bar that there exists a fork that I own from this upstream? Currently, GitHub has the repos/owner/id/forks API endpoint that returns upto 100 entries if you explicitly mention it. I don't see any parameters for creating a custom query for this particular problem. Counting in the rate-limiting and stuff, I don't think it's possible to know this using this API endpoint if I had say a fork of the linux project where over 20k+ forks exist. Is there any fast and efficient way to know this?

Note: I don't want to use authentication if at all possible.


Solution

  • New option (June 2022), directly on GitHub (instead of locally through API)

    The repository fork button now displays existing forks

    A dropdown has been added to the Fork button to help you quickly find your forks of a repository. This includes forks in your personal account and in organizations that you're a member of.

    Example of the "your existing forks" dropdown -- https://i0.wp.com/user-images.githubusercontent.com/771134/175119425-5ca5d020-7acb-4f1a-84bf-272980717f78.png?ssl=1

    This feature was inspired by Refined GitHub – an impressive open source project maintained by @fregante.
    The feature was requested of GitHub through the GitHub Stars program.

    Read more about forking a repository in the GitHub documentation.

    We appreciate feedback on this and other topics in GitHub's public feedback discussions.