【git】git commit模板
【git】git commit模板
目录
- 【git】git commit模板
- 1.使用git commit 模板
- 操作步骤:
- 使用示例:
- 2. gitlab merge 模板
1.使用git commit 模板
操作步骤:
-
设置模板路径,其中path就是commit模板路径
git config --global commit.template path
-
设置模板使用什么软件打开
git config --global core.editor [编辑器名字]
-
commit模板
fix(<模块>): <描述>#<具体描述>#<问题单号># type 字段包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 # scope:用于说明 commit 影响的范围,比如数据层、控制层、视图层等等。 # subject:是 commit 目的的简短描述,不超过50个字符 # Body:部分是对本次 commit 的详细描述,可以分成多行 # Footer:用来关闭 Issue或以BREAKING CHANGE开头,后面是对变动的描述、以及变动理由和迁移方法
使用示例:
-
(a.)在/home/xxx目录下创建一个commit.template文件
vim commit.template 【模块名称】: 【修改描述】: 【问题/需求单号】:
-
(b.)设置模板路径
git config --global commit.template /home/xxx/commit.template
-
(c.)设置编辑器
git config --global core.editor vim //这里设置vim,也可以设置text,egit等其他编辑器
-
(d.)修改文件,执行
git add . // 添加工作区的修改文件到缓存区 git commit // 该命令会自动弹出如下弹框,只需编辑后面的内容即可 git push origin dev // 推送到远端仓库
2. gitlab merge 模板
-
在项目的根目录下创建目录:
.gitlab/merge_request_templates
-
在上述目录中添加模板,文件需要为md格式,如:
fixbugs-template.md //修改bugs模板 feature-template.md //新增特性模板
-
模板内容参考
【bugs单号】: xxx 【问题原因】:xxx 【修改描述】: 本次提交修改了xxx问题 【修改时间】:2020-11-19 【修改人】:xx
-
合并时选择对应的模板