hub icon indicating copy to clipboard operation
hub copied to clipboard

Support Repository Templates

Open jamiekyle-eb opened this issue 5 years ago • 9 comments

GitHub just added support for using repositories as templates it would be great if the hub create command supported them:

hub create -t user/repo

jamiekyle-eb avatar Jun 07 '19 17:06 jamiekyle-eb

这个鬼东东怎么用起来?

odon0007 avatar Jun 11 '19 14:06 odon0007

I'm translating the above as "How is this [adj: ] thing used?" (Sorry I can't translate 鬼 in context)


From the /generate page on a "template" repository, you can create a new repository by copying the contents of the template repository (without its git history I assume).

However, it appears that GitHub has not yet built an API endpoint for doing the same programatically. So hub may not be able to do this yet.

jamiekyle-eb avatar Jun 11 '19 17:06 jamiekyle-eb

I'm translating the above as "How is this [adj: ] thing used?" (Sorry I can't translate 鬼 in context)

From the /generate page on a "template" repository, you can create a new repository by copying the contents of the template repository (without its git history I assume).

However, it appears that GitHub has not yet built an API endpoint for doing the same programatically. So hub may not be able to do this yet.

Yes, you're right.

odon0007 avatar Jun 12 '19 01:06 odon0007

Great idea, but the GitHub API doesn't support repo templates yet, and until it does, there's nothing that we can do from hub.

Closing to keep the issue backlog clean.

mislav avatar Jun 12 '19 15:06 mislav

Will reopen as this will likely be re-requested more and people need to understand that we are unable to implement this right now, but that we might be in the future.

mislav avatar Jun 17 '19 00:06 mislav

Seems simple

kandice1978 avatar Jun 24 '19 13:06 kandice1978

This API is now available under preview: https://developer.github.com/v3/repos/#create-repository-using-a-repository-template

However, it doesn't fit into how hub create is currently designed:

  • The create command is meant to be used within an existing local git repo to create a destination on GitHub for it to be pushed to. The rough steps are:
    1. Within existing working directory: git init;
    2. Create GitHub repository;
    3. git push -u origin HEAD.
  • Creating a GitHub repo from a template would create a new repository that would then need to be cloned locally into a new local git repo. The rough steps would be:
    1. Create a GitHub repository from template;
    2. Clone the new repository.

So you see, these operations would have completely orthogonal uses. This is why at the moment, I suggest that we don't extend the hub create command with template repo functionality.

mislav avatar Sep 21 '19 14:09 mislav

An example of a manual approach for generating repositories from templates using hub api: https://github.com/mislav/hub-api-utils/blob/master/bin/hub-create-from-template

mislav avatar Sep 21 '19 15:09 mislav

It would be good to have it in hub directly. But thanks for the api solution.

ericovasconcelos avatar Jul 09 '20 13:07 ericovasconcelos