Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple templates for Pull Requests on Github

According to documentation I had to create a PULL_REQUEST_TEMPLATE folder in .github folder.

Then add my pull_request_first_template and pull_request_second_template.md into PULL_REQUEST_TEMPLATE folder.

When I try to open a new PR, no templates are being displayed, not speaking of even switching between them.

Seems like templates are not displaying at all. Is there a solution to that?

like image 462
Fill Avatar asked Sep 05 '25 03:09

Fill


1 Answers

You can create a manual template selection, such that at least developers who open a PR can click on a link to get to their respective template:

  1. Assuming you have two templates group_a_template.md and group_b_template.md under .github/PULL_REQUEST_TEMPLATE

  2. Create the default template .github/pull_request_template.md with the following content

    Please go to the `Preview` tab and select the appropriate sub-template:
    
    * [Group A](?expand=1&template=group_a_template.md)
    * [Group B](?expand=1&template=group_b_template.md)
    

In this way, people who open a PR interactively in the UI will first get to the default template and can open their respective target template from the "Preview" view.

Not optimal, but more convenient than patching the URL manually every time you submit a PR.

like image 85
timon-k Avatar answered Sep 07 '25 20:09

timon-k