Open salewski opened 5 years ago
For renaming a "fork" remote to "origin" (and related), there is a prototype script in the contrib/
directory:
contrib/gh-remote-fixname-fork-to-origin
Example usage:
$ gh-remote-fixname-fork-to-origin
gh-remote-fixname-fork-to-origin (info): no remote named 'origin' found (okay)
gh-remote-fixname-fork-to-origin (info): renaming remote 'fork' => 'origin'
gh-remote-fixname-fork-to-origin (info): changing git-config key 'hub.forkremote' value from 'fork' to 'origin'
$ for rname in my-repo1 my-repo2 my-repo3; do ( unset CDPATH; cd "$rname" && echo && echo working on: $rname && gh-remote-fixname-fork-to-origin ) || break; done
working on: my-repo1
gh-remote-fixname-fork-to-origin (info): no remote named 'origin' found (okay)
gh-remote-fixname-fork-to-origin (info): renaming remote 'fork' => 'origin'
gh-remote-fixname-fork-to-origin (info): changing git-config key 'hub.forkremote' value from 'fork' to 'origin'
working on: my-repo3
gh-remote-fixname-fork-to-origin (info): no remote named 'origin' found (okay)
gh-remote-fixname-fork-to-origin (info): renaming remote 'fork' => 'origin'
gh-remote-fixname-fork-to-origin (info): changing git-config key 'hub.forkremote' value from 'fork' to 'origin'
working on: my-repo3
gh-remote-fixname-fork-to-origin (info): no remote named 'origin' found (okay)
gh-remote-fixname-fork-to-origin (info): renaming remote 'fork' => 'origin'
gh-remote-fixname-fork-to-origin (info): changing git-config key 'hub.forkremote' value from 'fork' to 'origin'
This issue is related to issue #38 and issue #39.
With changes in the default behavior of the git-hub tool when cloning repositories at that tool's 1.0.0 release (see issue #39 for more info), I have collections of repos beneath a common parent directory that have inconsistent setups: those that were cloned using pre-1.0.0 verions of git-hub have an 'origin' remote that points to the user's GitHub fork and have a non-triangular setup. Those that were cloned using 1.0.0 or later versions of git-hub have a 'fork' remote that points to the user's GitHub fork and have a triangular setup.
While both setups have their adherents, having a collection of repos setup inconsistently is confusing. We should provide tooling to report on such inconsistencies on locally cloned repos beneath a given directory, and also provide ways to migrate them all from one setup to the other.
For example, here's a one-liner to detect all repos that have been setup with a 'fork' remote: