Creating a Pull Request Template on GitHub: A Step-by-Step Guide with an Example Template

A pull request template is a way to standardize the information that contributors include when they open a pull request on GitHub. This can be useful for ensuring that all of the necessary information is included, and that it is presented in a consistent way.

To create a pull request template, follow these steps:

  1. Navigate to your repository on GitHub and click on the "Settings" tab.
  2. In the left-hand menu, click on "Options".
  3. Scroll down to the "Pull request templates" section.
  4. Click on the "Add pull request template" button.
  5. Enter a name for your template, such as "default".
  6. In the editor that appears, enter the content of your template. This can include text, Markdown formatting, and GitHub Flavored Markdown (GFM) syntax.

Did you know that you can also get automated summaries of the code by using What The Diff? What The Diff reads the code and provides a summary of the changes in seconds without using a template or manually writing a summary.

Here is an example template:

## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
  Once you have created your template, it will appear in the dropdown menu when contributors open a new pull request in your repository. They can then select the template and fill in the information as needed.

It's also possible to customize the pull request template for individual branches in your repository, if you want to use different templates for different purposes. For more information, see the GitHub documentation on creating a pull request template.