GitHub 中使用 issues 模版和 pull request 模版
1、issues 模版
1)默认模版
- 在代码库新建目录:
.github
- 在
.github
目录下添加ISSUE_TEMPLATE.md
文件作为 issues 默认模版。当创建 issue 时,若未建立多模版或选择了Open a regular issue
时,系统会引用该模版。
2)多模版
- 在代码库新建目录:
.github/ISSUE_TEMPLATE
- 该目录下可添加多个
.md
文件作为 issues 模版。当创建 issue 时,系统会展示这些模版供选择。 .md
文件参考格式如下:
1 | --- |
3)注意事项
- issues 的默认模版和多模版可同时存在。
- 关于 issues 模版的描述可详见帮助文档:https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository/
2、pull request 模版
1)默认模版
- 在代码库新建目录:
.github
- 在
.github
目录下添加PULL_REQUEST_TEMPLATE.md
文件作为 pull request 默认模版。当创建不带参数的 pull request 时,系统会引用该模版。
2)多模版
- 在代码库新建目录:
.github/PULL_REQUEST_TEMPLATE
- 该目录下可添加多个
.md
文件作为 pull request 模版。 - pull request 模版要通过查询参数来调用。例如,要使用
pr-template-1.md
这个模版,可使用如下查询:
1 | https://github.com/用户名/代码库名称/compare/分支名称?expand=1&template=pr-template-1.md |
或参考 GitHub 帮助文档的格式,如下。两者效果相同。
1 | https://github.com/用户名/代码库名称/compare/master...分支名称?expand=1&template=pr-template-1.md |
- 可选查询参数
expand=1
,直接跳转到 pull request 界面。如果不带此参数会先到 compare 界面,需手动进入 pull request 界面。template=pr-template-1.md
,调用名为pr-template-1.md
的模版。如果不带此参数,则调用默认模版。title=New+bug+report
(或者title=New%20bug%20report
),指定 pull request 的标题为New bug report
- 其他参数可详见帮助文档:https://help.github.com/articles/about-automation-for-issues-and-pull-requests-with-query-parameters/
3)注意事项
- pull request 的默认模版和多模版可同时存在。
- 关于 pull request 模版的描述可详见帮助文档:https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/