New Github Template Repository Feature

Asterios Raptis
3 min readJan 27, 2021

Github provides a great new feature that is called “Template repository”. This means that you can make an existing repository to a “Template repository” that you can afterwards generate new repositories with exactly the same directory structure, branches, and files.

It is very simple to make an existing repository to a “Template repository”. From the main page of the repository you have to go to the Settings of the project.

Settings

On the Settings page select the checkbox “Template repository” as it is shown in the following image

Thats it. Now the repository is a “Template repository” and can be templated for a new repository.

Create a Template repository for java libraries

I created a “Template repository” for templating java libraries as described above. As you can see from the above image the name of the Template repository is “java-library-template”. The downside of “Template repository” is that all directory structure, branches, and files is the same as in the template repository. There for i created a rename process that adapts the new repository to the current name of the project.

So if you want to create a copy of the repository you have to click the green ‘Use this template’ button at the top right.

This will bring you to the create a new repository page

Here you give the name and the description of the new repository and optional you can include all branches if you check the checkbox.

After you have checkout your repository locally you have to execute the unit test method InitialTemplateTest#testRenameToConcreteProject that is disabled.

So you have first to adapt the project description to your project description and then remove the annotation Disabled and run this unit test method InitialTemplateTest#testRenameToConcreteProject for enable it and than run it. This will adapt all related files that fits to your repository.

That it.

Happy coding

--

--

Asterios Raptis

Asterios Raptis is a Fullstack Developer and Software Consultant with over three decades of experience in the software development