Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

GitHub introduces ‘Template repository’ for easy boilerplate code management and distribution

Save for later
  • 2 min read
  • 10 Jun 2019

article-image

Yesterday GitHub introduced ‘Template repository’ using which you can share boilerplate code and directory structure across projects easily. This is similar to the idea of ‘Boilr’ and ‘Cookiecutter’.

https://twitter.com/github/status/1136671651540738048

How to create a GitHub template repository?


As per its name, ‘Template repository’ enable developers to mark a repository as a template, which they can use later for creating new repositories containing all of the template repository’s files and folders.

You can create a new template repository or mark an existing one as a template with admin permissions. Just navigate to the Settings page and then click on the ‘Template repository’ checkbox. Once the template repository is created anyone who has access to it will be able to generate a new repository with same directory structure and files via ‘Use this template’ button.

github-introduces-template-repository-for-easy-boilerplate-code-management-and-distribution-img-0

Source: GitHub


All the templates that you own, have access to, or have used in a previous project will also be available to you when creating a new repository through ‘Choose a template’ drop-down. Every template repository will have a new URL ‘/generate’ endpoint that will allow you to distribute your template more efficiently. You just need to link your template users directly to this endpoint.

github-introduces-template-repository-for-easy-boilerplate-code-management-and-distribution-img-1

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at £16.99/month. Cancel anytime

Source: GitHub


Templating is similar to cloning a repository, except it does not retain the history of the repository unlike cloning and gives users a clean new project with an initial commit. Though this function is still pretty basic, as GitHub will add more functionality in the future, it will be useful for junior developers and beginners to help them get started. Here’s what a Hacker News user believes we can do with this feature:

This is a part of something which could become a very powerful pattern: community-wide templates which include many best practices in a single commit:

- Pre-commit hooks for linting/formatting and unit tests.

- Basic CI pipeline configuration with at least build, test and release/deploy phases.

- Package installation configuration for the frameworks you want.

- Container/VM configuration for the languages you want to enable cross-platform and future-proof development.

- Documentation to get started with it all.

Read the official announcement by GitHub for more details.

Github Sponsors: Could corporate strategy eat FOSS culture for dinner?

GitHub Satellite 2019 focuses on community, security, and enterprise

Atlassian Bitbucket, GitHub, and GitLab take collective steps against the Git ransomware attack