askvity

Step-by-Step Guide to Creating a Pull Request Template

Published in GitHub Templates 4 mins read

To create a pull request template in GitHub, you'll need to add a specific markdown file to your repository that GitHub will automatically detect and use. This template helps standardize pull requests, ensuring all necessary information is included.

Follow these precise steps to set up a pull request template in your GitHub repository:

1. Navigate to Your Repository

First, navigate to the main page of the repository where you wish to create the pull request template. This is the repository's home page, showing the list of files and folders.

2. Create a New File

Once on the main repository page:

  • Above the list of files, locate and select the Add file dropdown menu.
  • From the dropdown options, click on Create new file. This action will open a new page where you can define the file's name and content.

3. Choose the Correct File Name and Location

This is a critical step for GitHub to recognize your template. In the file name field, you must specify the file path and name. For a repository-wide pull request template, it's best practice to place it in the .github directory.

Here are the common options for your template file:

Template Type File Path and Name Description
Single Template .github/PULL_REQUEST_TEMPLATE.md This is the most common and straightforward method. When a new pull request is opened, this template will automatically load. You can also place this directly in the root of your repository (e.g., PULL_REQUEST_TEMPLATE.md), but the .github directory is preferred for organization.
Multiple Templates .github/PULL_REQUEST_TEMPLATE/your_template_name.md For more complex projects, you can offer multiple pull request templates. In this case, GitHub will prompt contributors to choose a template when creating a new pull request. Replace your_template_name.md with a descriptive name (e.g., feature_request.md, bug_fix.md).

Example for a single template: Type .github/PULL_REQUEST_TEMPLATE.md into the file name field.

4. Add Your Template Content

In the body of the new file, add your pull request template. This is where you define the structure and content that contributors will see when opening a new pull request. Use Markdown syntax for formatting.

Example Pull Request Template Content:

---
name: Feature Request
about: Suggest an idea for this project
title: '[FEAT] '
labels: enhancement
assignees: ''
---

## Description

Please provide a clear and concise description of the new feature.

## Related Issues

Link any related issues here (e.g., `Closes #123`, `Fixes #456`).

## Checklist

*   [ ] I have read the [CONTRIBUTING.md](link-to-your-contributing-guide) and [CODE_OF_CONDUCT.md](link-to-your-code-of-conduct) files.
*   [ ] I have tested my changes thoroughly.
*   [ ] Documentation has been updated (if applicable).

## Screenshots (if applicable)

If your changes include UI updates, please provide screenshots or GIFs here.

## Additional Notes

Add any other relevant information here.

5. Commit Your Changes

Once you have added the template content, you need to save the file:

  • Scroll down to the "Commit changes" section.
  • Provide a descriptive commit message (e.g., "Add pull request template").
  • Choose whether to commit directly to the main branch or create a new branch.
  • Finally, click Commit changes... to finalize the creation of your pull request template.

Once committed, the template will be active. The next time someone opens a new pull request in your repository, they will automatically see the pre-filled template, guiding them to provide all necessary details.

Related Articles