4

More specifically, how do I tell if the origin of the repo on disk is a fork of some repo? I am thinking that it should be some API call, but I am not sure. Can I rely on "remote.upstream.url"?

Vadim Kotov
  • 7,766
  • 8
  • 46
  • 61
mpersico
  • 642
  • 8
  • 17

1 Answers1

4

You could use the GitHub API for Repositories to get a specific repo

GET /repos/:owner/:repo

(you can use a curl call from command line)

The JSON answer will include a "fork" field: value true or false.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • 1
    AHA! I can ask MY repo what is it is a fork of. So :owner/:repo comes from `git config --get remote.origin.url`, looking for `"fork": true` and `"full_name:"` in `"parent"`. Thank you. – mpersico Oct 29 '19 at 21:01
  • 1
    @mpersico Exactly. Or, as I mention in https://stackoverflow.com/a/32991784/6309, `git remote get-url origin`. – VonC Oct 30 '19 at 07:20
  • AHA2! I’ll be updating with this gem today. I try to read the release notes every time my machine gets a new git package but sometimes I miss it. – mpersico Oct 30 '19 at 11:56