Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Pull Requests template not showing

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.
like image 378
ZCode Avatar asked Sep 02 '18 16:09

ZCode


People also ask

How do I add a template to a pull request?

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.


3 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.

like image 176
Anand Avatar answered Oct 19 '22 12:10

Anand


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

like image 14
Peter Avatar answered Oct 19 '22 12:10

Peter


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.

like image 9
Fahad Azeem Avatar answered Oct 19 '22 13:10

Fahad Azeem