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:
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.
The easiest way to add a pull request template to your repository is by adding a file called pull_request_template.md in the root of your directory. It's a markdown file, so you can use any of the markdown that is available to you. More about markdown in the mastering markdown syntax guide.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With