JavaRush /Java Blog /Random EN /Optimizing work with your projects on GitHub: getting to ...

Optimizing work with your projects on GitHub: getting to know the Github Template Repository

Published in the Random EN group
Hello everyone, CodeGym community! Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 1 Today we will talk about open source and what is needed to create a quality project, IN ADDITION to the code that is being written. It is important to write a useful product. But no less important is the correct design of the repository (project repository on GitHub). This will help in the implementation of another key point - product promotion. Even if the project is super cool, but if it is poorly designed, it is not described at least in the README (you can read about what README is here), a license is not indicated, etc., etc., there will be no success. It's just that no one will notice. And if someone notices, they won't know how to interact with them. There are many things that need to be filled in from time to time, and every time copy-paste is not from the hands of the programmer, and just for this this summer, GitHub released the Template Repository feature that helps with this. So to speak, to automate the process of creating new projects. Today we will deal with what a Repository is, what a Template Repository is. Let's describe what should be in the project in addition to the code, what things you need to focus on. Let's create a Template Repository from scratch, add everything you need from my point of view. And finally, we will apply the Template Repository when creating a new repository. But first, let's deal with the terms.

Repository - something like a folder for a project in GitHub. The repository contains all the files that are related to the project. It stores the entire history of project changes, which is very important.

Using the Issues tab, you can create defects, improvements, questions for the project.

Using Projects , you can create kanban boards to track the status of issues (issues), their execution and planning.

Template repository is a template from which new repositories can be created. A template that contains common code for all repositories.

Theory: what should be in the general repository of any project Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 2Every open source project on GitHub should have a well-described Community Profile , which contains the following elements.

1.Issue template

Here you need to describe the rules for creating an issue in the repository: how they should be called, what the label will be, who will be assigned to it. When creating a new Issue, the following options will be offered:
  • Bug report - creating an issue in order to describe a defect on the project;
  • Feature request - a proposal for a new idea for the project;
  • Improvement request - a proposal for improvement on the project;
  • Custom issue template - if other options do not fit, you can use an empty template.
An example of what this looks like can be seen here .

2. License

The license under which the project is written. It is necessary so that those who will use the project know what is guaranteed and what is not. For example, the Apache License 2.0 says the following: Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 3

3 README

This is a description of the project, its business card. Everything that needs to be said about the project should be here. Of course, it will need to be described each time, taking into account the specifics of the project, but the headings will be the same. For example:
  • Overview - a brief description of the project;
  • Usage - how to use the project;
  • Building - how to start the project, what is needed for this;
  • Troubleshooting - describes what problems you may encounter and how to solve them;
  • Release Notes - description of changes depending on the version;
  • Authors - do not forget about yourself loved ones;
  • Contributing - a description of how you can participate in the development of the project;
  • Code of Conduct - description of the rules of participation;
  • RELEASE_NOTES is a file that records all changes for new versions. It's good practice to put this in a separate document and keep a link to go in the README;
  • CONTRIBUTING - a file that describes how you can contribute to the development of this project. Made as a separate file for the Contributing header in the README;
  • CODE_OF_CONDUCT - a file that describes the rules for participating in the development of the project;
  • Pull Request template - a template for those who will create a pull-request.
All these things are used from project to project, regardless of the programming language or its specifics.

Practice: creating your own template

As the saying goes, we move from words to deeds. Now, with an example, I'll show you how to create your own template.
  1. The first thing you need is a GitHub account / sign up there .

  2. Create a new repository: to do this, in the upper right corner, click +

    Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 4
  3. When creating, fill in:

    • Repository name - in my case repository-template;
    • Description - a brief description of the project;
    • we leave Public, although you can choose Private;
    • Check the README initialization checkbox:

      Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 5
    • Select the license under which the project will be:

      Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 6

      Since in my case the template is general, gitignore is not needed either: it will be added for a specific project and programming language.

      Therefore, we click Create Repository , thereby completing the creation process. The system will automatically transfer us to a freshly created repository.

  4. Filling Community Profile : in the created repository, go to the Insights tab and select Community :

    Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 7

    As you can see, it remains to fill out the Code of Conduce, Contributing, Issue Template, Pull Request template.

    Using the Code of Conduct example, we will show how to add them to the project.

    Click add , the system prompts you to choose Contributor Covenant or Citizen Code of Conduct :

    Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 8

    I choose the first one and click Review and Submit .

    Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 9

    Further, it will be possible to edit this file and already commit.

    At the bottom, select the Commit directly to the master branch option and click Commit new file :

    Optimizing the work with our projects on GitHub: getting to know the Github Template Repository - 10

    As a result, if we go back to the Community Profile , we will find that the Code of Conduct is marked as added:

    Optimizing work with your projects on GitHub: getting to know the Github Template Repository - 11

    Contributing and Issue Template are added in the same way, so I won't show them. Do it yourself ;)

  5. Add a Pull Request template .

    But let's talk about this separately.

    I don’t know why GitHub didn’t add the same convenient option for customizing the Pull-Request template, so I’ll have to study the Murzilka documentation and add it manually.

    To do this, in the root of the repository, click Create new file :

    Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 12

    The file name should be: .github/pull_request_template.md .

    Add what you need to the template and click Commit new file , as we did above. I did not intend to reinvent the wheel and found an example that seemed to me quite usable.

    Thus, the entire Community Profile will be filled in:

    Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 13
  6. Add the Template Repository marker .

    To do this, go to the Settings option in the repository and check the box where it says Template Repository:

    Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 14

    And that's it, the template for creating new projects is ready. Thus, we will save a lot of time in the future when we need to create new projects. It will also help you not to miss important details, as it often happens that you forget to add something, such as a license or a clear template for an issue.

How to use the Template Repository

There are two options to use:

  1. When the template is directly owned by you: when creating a new repository, you will be given the option to create based on a template from the list of templates you own:

    Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 15
  2. When the template is alien: there are no particular problems here either. Go to that template and click the Use this template button . Here I'll use the animation from the official docs:

Summing up

In this article, we've covered:
  • what is a GitHub repository;
  • what is Template repository;
  • what should be in the Template repository;
  • how to create a Template Repository;
  • how to use the Template Repository.
Of course, based on this template, you can already create more specific ones. For example, I created more templates with configured maven or gradle build systems. Further more: you can create a Spring Boot Repository Template based on the last two. To group all the templates, I created a template-repository organization on GitHub with all the templates. Follow my GitHub account Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 16

useful links

Optimizing the work with your projects on GitHub: getting to know the Github Template Repository - 17

More of my articles

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION