44

I wanted to create custom Pull Requests template for my Github repo (internal version in my company and not on Github.com), so I followed instructions on this link. I followed below steps:

  1. Created the new template file in the location: [my-repo]/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md.
  2. Merged this new file into master.
  3. Created a new branch from master, commited some changes into new branch.
  4. Created a new Pull Request to master, but the template did not show up.

Creating the new PR did not show up the template I had created. Similar steps for creating new issue templates work fine, but PR templates arent working. I would like to add different templates inside PULL_REQUEST_TEMPLATE folder in order to create multiple pull request templates like feature template, bug-fix template etc. My PR template markdown has the following in it:

---
name: Design Review
about: Design Review issue template

---

# PR Change Description
This PR is to add a new vendor type.

6 Answers 6

24

You must create templates on the repository's default branch. Templates created in other branches are not available for collaborators to use. You can store your pull request template in the repository's visible root directory, the docs folder, or the hidden .github directory. Pull request template filenames are not case sensitive, and can have an extension such as .md or .txt.

18

GitHub will by default load the file .github/PULL_REQUEST_TEMPLATE.md as the PR template.

However it is possible to have multiple templates and reference them using a query string on the url, like this: https://github.com/octo-org/octo-repo/compare/master...pull-request-test?template=pr_template.md

That will load the template pr_template.md from .github/PULL_REQUEST_TEMPLATE/pr_template.md, where master is the destination branch and pull-request-test is the branch to merge in.

Similarly for issues

https://github.com/octo-org/octo-repo/issues/new?template=issue_template.md

The docs are not that well written on this point, however the full set of parameters for the PR create form is listed here: https://help.github.com/en/github/managing-your-work-on-github/about-automation-for-issues-and-pull-requests-with-query-parameters, but it even has the wrong url for this specific example

For issues there is now a selector for templates configured through yaml so you can choose between templates without using query strings, perhaps something similar will come for PR's later https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository

2
  • 1
    ...using a query string on the url, You mean manually typing it to the end of the URL? Is there anyways to automatically add that template?
    – tir38
    Feb 23, 2021 at 22:19
  • That depends, if you have only one template simply name it .github/PULL_REQUEST_TEMPLATE.md then it will be automatically added. If you have multiple and want people to choose a template, then my best suggestion would be to add direct links to issue adding in your readme file to the different templates
    – Peter
    Mar 9, 2021 at 22:16
10

I tried by adding my pull_request_template.md file to .github/PULL_REQUEST_TEMPLATE/pull_request_template.md path

but it did not work then I moved my file to .github/pull_request_template.md path i.e. removed the subdirectory PULL_REQUEST_TEMPLATE and boom it worked.

So if you don't have multiple templates then you do not need to create PULL_REQUEST_TEMPLATE subdirectory and make sure you create your pull_request_template.md in your default branch which is mostly master.

5

You should only create the file inside the .github folder, not a PULL_REQUEST_TEMPLATE folder.

Moving your .md file to .github/PULL_REQUEST_TEMPLATE.md should work.

5
  • 2
    Thanks @Gabriel Caruso, this resolved creating a single PR. But I still need to create templates in PULL_REQUEST_TEMPLATE folder where I initially started, so I can then add multiple templates like: new feature, bug-fix etc. That still doesn't seem to work. I tried using different names inside PULL_REQUEST_TEMPLATE folder, but it still doesnt show up when creating a new PR.
    – ZCode
    Sep 2, 2018 at 18:23
  • 6
    @Gabriel Caruso this is incorrect. You CAN have only one file for the default template, but it clearly states on the documentation that if you want more templates you need to make a PULL_REQUEST_TEMPLATE folder: help.github.com/articles/…. However, it still doesn't seem to work.
    – teradyl
    Oct 31, 2018 at 22:16
  • 1
    As @teradyl said, I don't think it makes sense to say that ZCode 's procedure was wrong. It's github that has clearly a bug in their implementation of templating.
    – alecive
    Aug 26, 2019 at 19:39
  • 1
    The PULL_REQUEST_TEMPLATE folder only works when you call the create PR with query parameters. That way you can specify which template to use. It is not an error in the docs, it is just not that well written. help.github.com/en/github/managing-your-work-on-github/…
    – Peter
    Mar 12, 2020 at 10:04
  • 1
    @Peter could you consider posting your comment as an answer? The information should be spotlighted. Jun 27, 2020 at 14:00
2

In my case, the name of the file was .github/pull_request_template.md as described in GitHub docs and it didn't work until I renamed it to .github/PULL_REQUEST_TEMPLATE.md.

P.S. I was moving the file around different folders prior to this change, so it could be that something got stuck in GitHub cache or so.

0

You could check if the file really is in your \.github directory. In my case, vscode "visually collapsed" \.github into \.github\workflows so I accidentally created the file in \.github\workflows.

Moved it up a directory so it really was in \.github and now it's displayed as expected. Might be obvious, but took me ~10 minutes to spot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.