Git Commit Message Format

Never leave todays’s work tomorrow.

1. Why need format

It will benefit ourselves and others.

2. Specific format

Let’s first see the abstract formula:

<type>(<scope>): <subject>

example:

fix(controller) : nullpointexception
type

It is used to explain the type of this commit and can only be in the following 7 types:

  • feat:add new function(feature)of your project.
  • fix:fix bugs.
  • docs:add documentation.
  • style: just modify the style of code,it does’n affect the execution of code.
  • refactor:neither feat nor fix,it may affect the execution of code.
  • test:add test unit.
  • chore:change of build tools or helper and enviroment.
scope

It is used to explain the scope of this commit,such as view layer,model layer,controller layer and so on.

subject

It is a short description of this commit and it can not be in excess of 50 character.

  • start with verb and use first persion present tense,such as change instead of changes nor changed
  • make sure the first character should be lower case
  • do not add period(.) at the end of your subject

As you see,above tips of subject also follow it’s rules.


THE END.

### Git Format-Patch 使用方法 `git format-patch` 是用于创建补丁文件的工具,这些补丁文件可以被其他开发者应用来重现特定范围内的更改。此命令通常用于电子邮件交流或跨仓库共享变更集。 #### 创建单个提交的 Patch 文件 对于仅需打包最近一次提交的情况: ```bash git format-patch -1 HEAD ``` 这将会生成一个名为 `0001-<commit message>.patch` 的文件[^4]。 #### 批量导出多个提交为 Patches 当想要把一系列连续的提交转换成独立的 patch 文件时,可以通过指定起始和结束提交ID之间的区间实现批量操作: ```bash git format-patch startCommitId...endCommitId -o /path/to/output/directory/ ``` 上述指令会依次处理从 `startCommitId` 到 `endCommitId` 范围内所有的提交记录,并将它们分别保存至 `/path/to/output/directory/` 下面作为单独的 .patch 文件[^1]. #### 自定义输出路径与命名规则 除了基本的功能外,还可以通过 `-o|--output-directory=<dir>` 参数设定输出目录以及利用模板化的方式控制最终产生的文件名格式。例如设置前缀或者调整编号样式等特性都可通过查阅官方文档获得更详细的配置选项说明[^3]. #### 应用已有的 Patch 文件 一旦拥有了由 `format-patch` 生产出来的 `.patch` 文件,则可借助于如下两种方式之一将其应用于当前项目环境中: - **自动提交模式**: 使用 `git am <filename.patch>` 可以直接读取并执行该补丁所描述的变化,同时还会保留原始作者信息完成新的提交动作。 - **手动审核模式**: 若只希望预览效果而不立即形成历史记录的话,则应该选用 `git apply filename.patch` 来达到目的,在确认无误后再决定是否进一步纳入版本控制系统管理之中.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值