身為一個開發者,天天碰 Git 也是很自然的事(茶)。
那每次伴隨著 commit 的 message 該怎麼寫比較清晰易懂呢?其實也沒有一定要怎麼打才是對的,不過還是有一些 guideline 可以拿來參考一下。

Short Form

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


  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests
  • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation


  • The subject contains succinct description of the change:
  • use the imperative, present tense: "change" not "changed" nor "changes"
  • don't capitalize first letter
  • no dot (.) at the end


  1. 首行精簡: the first line should be a short description, no more than 72 characters and does not end with a full stop;

  2. 頸行留白: the next line should be empty space;

  3. 解釋清楚: following this is an optional longer description, this should be written in regular paragraphs with full sentence structure;
    a. 為何重要: Why is this change necessary?
    b. 怎麼改的: How does it address the issue?
    c. 影響什麼: What side effects does this change have?

  4. 指出Bug: finally if this patch fixes an open bug, there should be a link to the bug report, in a paragraph by itself.


[PutSomeTag] Don't destroy MainWindow on delete-event, just hide it

This stops MainWindow being unreferenced, 
and prevents crashes caused by things which then try to use it.



Redirect user to the requested page after login

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

要不要把 commit msg 打清楚是見仁見智,我自己是覺得把有做的修正解釋清楚蠻重要的。雖然自己看修改的檔名也可以知道改了哪些東西,但畢竟都是要打,而且工作中難免會碰到 co-work 的時候,掌握一些基本的觀念,就可以寫出讓大家都看得懂的 commit message(就像好的註解一樣!)


comments powered by Disqus
Copyright © 2013 Andro Chen
Powered by Logdown and Greyshade
Favicon from The Noun Project