Creating new projects from an existing "boilerplate" repo

"Fork" isn't a Git concept. Are you confusing Git with Github? If you mean forking the project on Github, then it's the same as cloning the repo, and cloning sounds like what you're looking for. You'd just never push changes back to the "boilerplate" repo. You could, however use merging or rebasing to pull in updates to the boilerplate repo into the projects that spin off of it. If nothing like that is desirable, then why even do it with Git? Just make a recursive copy of the directory, and start from there.


Nothing wrong with @VonC's answer, but you can alternatively use hub to create a one-liner that effectively inits a new repo (locally and remotely) based on your seed repo:

clonefork() {
    hub clone "$1"
    cd "${1##*/}"
    hub fork
}

In your shell:

$ clonefork user/seed-repo

By "cloneforking" your seed repo, you also get a network graph showing all repos generated off of it.


Update June 2019, 6 years later:

See "Generate new repositories with repository templates "

Sharing boilerplate code across codebases is a constant pattern in software development.
Bootstrapping a new project with our favorite tools and directory structures helps programmers go from idea to “Hello world!” more efficiently and with less manual configuration.

Today, we’re excited to introduce repository templates to make boilerplate code management and distribution a first-class citizen on GitHub.

To get started, all you need to do is mark a repository as a template, and you’ll immediately be able to use it to generate new repositories with all of the template repository’s files and folders.

https://github.blog/wp-content/uploads/2019/06/repository-template.gif

Every template repository gets a new URL endpoint called /generate that allows you to distribute your template more efficiently


Original answer 2013:

Considering you will be storing your project on Github from one of the templates included in boilerplate GitHub project, I would:

  • Create a new empty repo on GitHub (no link with boilerplate, no need for a fork)
  • clone it
  • clone boilerplate in a separate location on your disk
  • copy the right template from the local boilerplate clone to your new locally cloned Github repo
  • (git add, git commit) Push that specific template back to your new Github repo.
  • start working from there

Tags:

Git

Github