写出好的 commit message
为何要关注提交信息
- 加快Reviewing Code的过程
- 帮助我们写好release note
- 5年后帮你快速想起来某个分支,tag或者 commit增加了什么功能,改变了哪些代码
- 让其他的开发者在运行
git blame的时候想跪谢 - 总之一个好的提交信息,会帮助你提高项目的整体质量
基本要求
- 第一行应该少于50个字。 随后是一个空行 第一行题目也可以写成:
Fix issue #8976 - 喜欢用 vim 的哥们把下面这行代码加入 .vimrc 文件中,来检查拼写和自动折行
autocmd Filetype gitcommit setlocal spell textwidth=
- 永远不在
git commit上增加-m <msg>或--message=<msg>参数,而单独写提交信息
一个不好的例子 git commit -m "Fix login bug"
一个推荐的 commit message 应该是这样:
Redirect user to the requested page after login https://trello.com/path/to/relevant/card Users were being redirected to the home page after login, which is less
useful than redirecting to the page they had originally requested before
being redirected to the login form. * Store requested path in a session variable
* Redirect to the stored location after successfully logging in the user
- 注释最好包含一个连接指向你们项目的 issue/story/card。一个完整的连接比一个 issue numbers 更好
- 提交信息中包含一个简短的故事,能让别人更容易理解你的项目
注释要回答如下信息
为什么这次修改是必要的?
要告诉 Reviewers,你的提交包含什么改变。让他们更容易审核代码和忽略无关的改变。
如何解决的问题?
这可不是说技术细节。看下面的两个例子:
Introduce a red/black tree to increase search speed
Remove <troublesome gem X>, which was causing <specific description of issue introduced by gem>
如果你的修改特别明显,就可以忽略这个。
这些变化可能影响哪些地方?
这是你最需要回答的问题。因为它会帮你发现在某个 branch 或 commit 中的做了过多的改动。一个提交尽量只做1,2个变化。
你的团队应该有一个自己的行为规则,规定每个 commit 和 branch 最多能含有多少个功能修改。
小提示
- 使用 fix, add, change 而不是 fixed, added, changed
- 永远别忘了第2行是空行
- 用 Line break 来分割提交信息,让它在某些软件里面更容易读
- 请将每次提交限定于完成一次逻辑功能。并且可能的话,适当地分解为多次小更新,以便每次小型提交都更易于理解。
例子
Fix bug where user can't signup. [Bug #] Users were unable to register if they hadn't visited the plans
and pricing page because we expected that tracking
information to exist for the logs we create after a user
signs up. I fixed this by adding a check to the logger
to ensure that if that information was not available
we weren't trying to write it.
Redirect user to the requested page after login https://trello.com/path/to/relevant/card Users were being redirected to the home page after login, which is less
useful than redirecting to the page they had originally requested before
being redirected to the login form. * Store requested path in a session variable
* Redirect to the stored location after successfully logging in the user
本文参考阅读
- A Note About Git Commit Messages
- Writing good commit messages
- Proper Git Commit Messages and an Elegant Git History
- A Better Git Commit
- 5 Useful Tips For A Better Commit Message
- whatthecommit
- 写好Git Commit信息的7个建议
写出好的 commit message的更多相关文章
- 如何写好git commit message
1.触发事件 我有这样一个版本库,里面包含两个学习用的练习项目:BookStore(以下简称BS)和PictureFriend(以下简称PF) 我在更改PF以后,未进行提交,同时又到BS中优化了一下文 ...
- 我是怎么写 Git Commit message 的?
目录 作用 用的什么规范? type scope subject body footer 参考文章 用的什么辅助工具? 作用 编写格式化的 commit message 能够大大提高代码的维护效率. ...
- [译]How to Write a Git Commit Message
原文: http://chris.beams.io/posts/git-commit/ 介绍:为什么好的commit message很重要 你浏览项目commit message的时候或多或少会有些困 ...
- Commit message 和 Change log 编写指南
来源:http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html Git 每次提交代码,都要写 Commit messa ...
- 让你用sublime写出最完美的python代码--windows环境
至少很长一段时间内,我个人用的一直是pycharm,也感觉挺好用的,也没啥大毛病 但是pycharm确实有点笨重,啥功能都有,但是有很多可能这辈子我也不会用到,并且pycharm打开的速度确实不敢恭维 ...
- Git 提交的正确姿势:Commit message 编写指南
http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html Git 每次提交代码,都要写 Commit message( ...
- 优化 Git Commit Message
目前很多项目都是通过 Git 进行管理的,Git 每次提交代码的过程中 提交说明 commit message 是必须的.但仅仅必须是不够的,好的提交说明可以帮助我们提高项目的整体质量. 作用与优点 ...
- (转)Git 提交的正确姿势:Commit message 编写指南
Git 每次提交代码,都要写 Commit message(提交说明),否则就不允许提交. $ git commit -m "hello world" 上面代码的-m参数,就是用来 ...
- 使用 Commitizen 撰写 Angular 规范的 commit message
本文为原创文章,转载请标明出处 目录 安装及配置 使用 1. 安装及配置 npm install -g commitizen npm install -g cz-conventional-change ...
随机推荐
- Jquery 仿 android Toast效果
JS代码如下: /** * 模仿android里面的Toast效果,主要是用于在不打断程序正常执行的情况下显示提示数据 * @param config * @return */var Toast = ...
- Code First开发系列之领域建模和管理实体关系
返回<8天掌握EF的Code First开发>总目录 本篇目录 理解Code First及其约定和配置 创建数据表结构 管理实体关系 三种继承模式 本章小结 自我测试 本篇的源码下载:点击 ...
- 剑指Offer面试题:16.合并两个排序的链表
PS:这也是一道出镜率极高的面试题,我相信很多童鞋都会很眼熟,就像于千万人之中遇见不期而遇的人,没有别的话可说,唯有轻轻地问一声:“哦,原来你也在这里? ” 一.题目:合并两个排序的链表 题目:输入两 ...
- [每日电路图] 10、两种MOS管的典型开关电路
下图是两种MOS管的典型应用:其中第一种NMOS管为高电平导通,低电平截断,Drain端接后面电路的接地端:第二种为PMOS管典型开关电路,为高电平断开,低电平导通,Drain端接后面电路的VCC端. ...
- iOS-在团队开发过程中控制代码版本
Cornerstone Svn简单使用指南: -- what if 负责编写 一.安装并拷贝项目 1.第一步:安装svn.2.第二步:第一个使用svn,找到“Check Out Working Cop ...
- 替代jquery1.9版本以前的toggle事件函数(开关)
以上文章为转载自http://blog.sina.com.cn/s/blog_50042fab0101c7a9.html var flag=1; $(".selector").cl ...
- Entity Framework Code First添加修改及删除单独实体
对于一个单独实体的通常操作有3种:添加新的实体.修改实体以及删除实体. 1.添加新的实体 Entity Framework Code First添加新的实体通过调用DbSet.Add()方法来实现. ...
- MVC遇上bootstrap后的ajax表单模型验证
MVC遇上bootstrap后的ajax表单验证 使用bootstrap后他由他自带的样式has-error,想要使用它就会比较麻烦,往常使用jqueyr.validate的话只有使用他自己的样式了, ...
- Hammer.js手势库 安卓4.0.4上的问题
Hammer.JS - v1.0.7dev - 2014-02-18 1.Hammer.JS 在安卓4.0.4 , 4.1上 touchmove事件丢失 https://code.google.com ...
- 字典 Key值转换为数组
public static string[] GetCategories() { Dictionary<string, int> itemMap = new Dictionary<s ...