How to Create a Simple GitHub Pull Request Template
A well-crafted pull request (PR) template can streamline the PR process, ensuring that all necessary information is included.
Here's how to create a simple, effective PR template for your GitHub repository.
In this article, we will create a checklist that a contributor can interact with on every Pull Request they open.
Understand the Purpose of a Pull Request Template
Before diving into the creation process, it's crucial to understand why a PR template is beneficial. A PR template:
- Encourages contributors to include relevant details.
- Standardizes the format of pull requests.
- Saves time for both contributors and maintainers.
Log into your GitHub account and navigate to the repository where you want to add the PR template. You can open the code locally or use the GUI on GitHub to add this file, as it's just a markdown file and shouldn't get too complicated.
Create the Template File
To get this to work, there is a special file naming convention you need to use:
This file also needs to be in one of three specific folders. You can include the
- The root directory (
- Inside the
.github/pull_request_template.md), which is a GitHub-specific file directory.
- Inside the
Write Your Template
pull_request_template.md file, write down the structure you want contributors to follow.
Here's a simple template to start with:
# Pull Request Template ## Description Please include a summary of the change and which issue is fixed. Also list any relevant context or decisions. ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Documentation update ## Checklist - [ ] I have read the CONTRIBUTING document. - [ ] My code follows the code style of this project. - [ ] I have added tests to cover my changes. - [ ] All new and existing tests passed.
Commit Your Template
After writing your template, commit the file to your repository:
- Enter a commit message, like "Add pull request template".
- Choose to commit directly to the
mainbranch or create a new branch.
- Click 'Commit new file'.
Test Your Template
Create a new pull request in your repository to ensure the template appears correctly.
It should automatically populate the pull request's description box.
This is a simple but effective way of giving people guidance on every PR and saves you from reaching out to developers on your team and asking them if they did do "x," "y," and "z."