Github Pull Requests template not showing

Viewed 11702

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

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.

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

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.

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.

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.

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.

Related