Friday, June 7, 2024

How to create Pull Request (PR) templates in Github repository | Creating a pull request template for your GitHub repository


Creating pull request (PR) templates in GitHub can help streamline the process of submitting PRs by providing a predefined structure. This ensures that all necessary information is included, making the review process more efficient. 

Step-by-Step Guide

  1. Navigate to Your Repository:

    • Go to the GitHub repository where you want to create a PR template.
  2. Create a .github Directory:

    • If it doesn't already exist, create a new directory named .github in the root of your repository. This is where GitHub looks for configuration files, including PR templates.
  3. Create a PULL_REQUEST_TEMPLATE File:

    • Inside the .github directory, create a file named PULL_REQUEST_TEMPLATE.md. This file will contain the template for your pull requests.

      4. Add Template Content:

  • Open the PULL_REQUEST_TEMPLATE.md file and add the content you want to include in your PR template. You can use Markdown to format the template. Here’s an example of a basic PR template:

## What type of PR is this? (check all applicable)
- [ ] 🍕 New Feature
- [ ] 🎨 Enhancment Feature
- [ ] 🐛 Bug
## Describe about your code changes
<!-- 
Please do not leave this blank 
This PR [adds/removes/fixes/replaces] the [feature/bug/etc]. 
-->
## Related Feature & Documents
<!-- 
Please use this format link issue numbers: Fixes #123
-->
## Screenshots/Recordings Link In Sharepoint
<!-- Visual changes require screenshots -->

## Created Unit tests, etc?
- [ ] 👍 yes
- [ ] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help
## Added to documentation?
- [ ] 📜 README.md
- [ ] 📕 wiki
- [ ] 🙅 no documentation needed
## [optional] Are there any post-deployment tasks we need to perform?

    5. Commit and Push:

  • Commit the PULL_REQUEST_TEMPLATE.md file to your repository and push it to GitHub.

git add .github/PULL_REQUEST_TEMPLATE.md 
git commit -m "Add pull request template" 
git push origin main

Optional: Multiple Templates

If you want to offer multiple PR templates, you can place them in the .github/PULL_REQUEST_TEMPLATE/ directory. Each template should be a separate Markdown file.

Using PR templates helps maintain consistency and completeness in pull requests, making it easier for reviewers to understand and review changes. Adjust the templates according to the needs and standards of your project.

Watch steps in YouTube channel:

No comments:

Post a Comment

What is GitHub Advanced Security for Azure DevOps | Configure GitHub Advanced Security for Azure DevOps

GitHub Advanced Security for Azure DevOps brings the  secret scanning, dependency scanning  and  CodeQL code scanning  solutions already ava...