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"?
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.
Another approach, using the GitHub CLI gh repo view
command:
gh repo view VonC/git-cred --json isFork
{
"isFork": false
}