Skip to main content
In this lesson we explain GitHub repository templates: what they are, how they differ from forks, and how to mark a repository as a template and create a new repository from it. Repository templates let you generate a new repository that copies the directory structure and files of the template repository without copying its commit history (unless you explicitly include branches). Templates are ideal for starter kits, examples, classroom assignments, and boilerplate projects where you want contributors to begin from a clean snapshot rather than inheriting an unrelated commit history.
Use repository templates to provide a clean starting point for new projects (e.g., starter kits, examples, or classroom assignments). Use forks when you need to continue work on a project while keeping the full history and a link to the upstream repository.

Fork vs Template — Key Differences

Below is a concise comparison of forks and repositories created from templates so you can choose the right workflow for your project. For authoritative guidance see the GitHub documentation: https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template

Create a repository from a template using the GitHub CLI

You can also generate a new repository from a template with the GitHub CLI. Example:
This command creates my-new-repo using the repository owner/template-repo as the template source. Now let’s walk through marking an existing repository as a template and creating a new repo from it. I’ll open the Block Buster repository in GitHub (this repository contains files such as .gitignore, README.md, index.html, script.js, and style.css).
This image shows a GitHub repository named "block-buster" with several files like .gitignore, README.md, index.html, script.js, and style.css. The repository is described as an enhanced version of the Block Buster Brick Breaker game with advanced features.
To make the repository a template, open the repository Settings and enable the “Template repository” option. Toggle it on to allow others to use the repository as a template.
The image shows the settings page of a GitHub repository where options for general settings, default branch, releases, and social preview are displayed. The repository is named "block-buster," and the "Template repository" option is highlighted.
After enabling the template option, return to the repository’s Code view. You’ll notice a “Use this template” button in the UI. Clicking that starts the process for creating a new repository based on the template. In the new-repository dialog you can set:
  • Owner (your account or an organization)
  • Repository name
  • Description
  • Visibility (public or private)
  • Whether to include all branches from the template or only the default branch
The image shows a GitHub interface for creating a new repository, with options for using a template, setting the owner, repository name, description, and visibility.
If you choose “only the default branch,” the new repository will start with a single commit (a snapshot of that branch). If you choose to include all branches, those branches (and their histories) will be copied into the new repository. Be intentional when including branches to avoid importing unwanted history.
A few important details about the resulting repository:
  • Choosing only the default branch creates a new repository with the template files and a single initial commit that represents the snapshot.
  • Choosing to include all branches will copy the selected branches into the new repository.
  • The new repository’s commit history is independent of the template (unless you include branches with history explicitly). It will not automatically contain the original repository’s full commit history unless those branches are included.

When to use templates vs forks (quick guidance)

  • Use a repository template when you want to give users a starting point without exposing or carrying over the original commit history. Ideal for templates, examples, and classroom assignments.
  • Use a fork to create a linked copy when you intend to continue development, retain full history, and contribute changes back to the upstream project.
That’s how you mark a repository as a template and create a new repository from it. Templates help maintain consistent, clean starting points for new projects, while forks are better when you need continuity with the original repository’s history.

Watch Video