Skip to content

feat: Add support for creating new repos based on an existing upstream #1424

@notheotherben

Description

@notheotherben

Is your feature request related to a problem? Please describe.
When creating new repositories, I would like to be able to specify that the repository is seeded from an initial repository (either a fork, or a template, in GitHub nomenclature). This action should, when working against GitHub repos, automatically create the appropriate fork/template instance instead of creating a new (unlinked) repo, enabling the "GitHub Flow" contribution workflow.

Describe the solution you'd like
I'd like to be able to provide a --from/--fork argument when running gt new, specifying a source repository from which the new repo should be seeded.

gt new gh:notheotherben/git-tool --from gh:SierraSoftworks/git-tool
gt new gh:notheotherben/git-tool --fork gh:SierraSoftworks/git-tool

When --from/--fork is provided, Git-Tool should:

  • Use GitClone { ... } to clone the --from repo into the desired destination path (instead of using GitInit { ... }).
  • Attempt to perform a fork/template instantiation using the GitHub API (instead of creating a new repo).
  • Update the origin URL to point at the correct repository (using GitRemote { ... }).
  • Add a new upstream remote pointing at the --from/--fork repository to enable fetching.

Describe alternatives you've considered
We also considered a new gt fork command which would create a fork of a specific repository, however this requires a user to learn a new command and would (if we deferred cloning until after the fork was completed) require polling for completion of an async GitHub operation, increasing complexity.

Metadata

Metadata

Labels

featureA new feature for Git-Tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions