Reputation: 304444
Using the github API, how can I determine if a repo has been forked from another repo? An example using gh api
would be ideal.
Context: I would like to apply some different automated processing to my github repos depending on whether or not they have been forked from another repo.
Upvotes: 2
Views: 268
Reputation: 1323883
To access your private repositories, use gh login
to authenticate yourself. Once authenticated, you will see your private repositories and any other resources to which your account has access.
The repos/
response contains a .fork
indicator.
echo ghp_YOUR_TOKEN | gh auth login --with-token
gh api --method=GET repos/<user>/<repo> --jq ".fork"
false/true
Upvotes: 3