Creating a new repo using another as a template is a great function, but I can only see how to use this ability on github.com. Can it be done entirely from command line? Perhaps without a remote?
I would like to use templates for a user to intialise a repo to store their secrets in, and it may not even require a remote, but its very important that it isn't connected to the original template repo for privacy. The .gitignore file and the folder tree provided are the most important functions that I'm hoping to provide the user with this ability.
In the command line, navigate to the root directory of your project. Initialize the local directory as a Git repository. Stage and commit all the files in your project. To create a repository for your project on GitHub, use the gh repo create subcommand.
Initializing a new repository: git init To create a new repo, you'll use the git init command.
June 2020: Since a template repository such as this one is a GitHub repository, you can:
.git
foldergit init .
git add .
git commit -m "First commit"
gh repo create
git push -u origin master
That way, everything is done form the command line.
Update Sept. 2020: the other approach through the GitHub CLI tool gh
, and mentions in Ben Gubler's answer, stems from PR 1590: "Create repositories from a template repo" from Mislav Marohnić and Colin Shum.
(merged in commit 99372f0)
gh repo create <new-repo-name> --template="<link-to-template-repo>"
# OR
gh repo create <new-repo-name> --template="<owner/template-repo>"
Try gh repo create myrepo --template someuser/sometemplate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With