Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub api - for a forked repository object, how to get what repository its forked from?

Tags:

github

api

GitHub api -

For the getRepos action, you will get a list of the user's repositories.

The repository objects that are returned have some information in them. However, they don't seem to have any information about "what repository am i forked from?"

How can I get that?

like image 556
Nicholas DiPiazza Avatar asked Sep 02 '13 21:09

Nicholas DiPiazza


People also ask

How do I find out who forked my GitHub repository?

Clicking the number of forks shows you the full network. From there you can click "members" to see who forked the repo.


1 Answers

In the "Get" section of the repo API, you can see two fields which address your question:

The parent and source objects are present when the repo is a fork:

  • parent is the repo this repo was forked from,
  • source is the ultimate source for the network.

When I get my fork of the git repo, I see:

curl -s "https://api.github.com/repos/VonC/git"

  "parent": {
    "id": 36502,
    "name": "git",
    "full_name": "git/git",
    "owner": {
      "login": "git",
      "id": 18133,

You can get the forked repo information by reading the content of the parent field.

like image 190
VonC Avatar answered Sep 19 '22 05:09

VonC