3

I've got a forked github repo on my machine, I'll call MYFORK.

It was forked from a repo I'll call MAIN_REPO

Is there a generic way from the command line to find out where MYFORK came from? ie the answer should be MAIN_REPO, not the url to my fork on github.

I'm open to git or command line github specific solutions, and am interested in solutions that don't require me to have manually added an "upstream" at some point, as implied here.

Community
  • 1
  • 1
Brad Parks
  • 66,836
  • 64
  • 257
  • 336

2 Answers2

1

It's a bit of work, but you could probably use e.g. octokit.rb or the github_api gem to write a small Ruby script that accesses the GitHub API to list all your repositories, searching for the one whose url field matches your origin remote, and for that object again look at the parent object's url field. That gives you the repository your repository was forked from. If you're interested in the ultimate source of all forks of forks, use the source object's url instead.

sschuberth
  • 28,386
  • 6
  • 101
  • 146
0

Your repo may have multiple "remotes" to sync changes from. You can list them with git remote -v. Sure, if your "fork" repo on the github, you will see only your fork in the "remotes" list, and there is no generic method to find "original" repo, except using github own api.

vitalyster
  • 4,980
  • 3
  • 19
  • 27