Brad Parks Brad Parks - 1 year ago 88
Git Question

Git - can I determine from the command line where a forked repo was forked from?

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


It was forked from a repo I'll call

Is there a generic way from the command line to find out where
came from? ie the answer should be
, 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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download