如何寫 git commit 訊息筆記 - fantasy0107/notes GitHub Wiki
範例
Summarize changes in around 50 characters or less
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.
Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded
by a single space, with blank lines in between, but conventions
vary here
If you use an issue tracker, put references to them at the bottom,
like this:
Resolves: #123
See also: #456, #789
結構
Style
Content
Metadata
7 條寫好 commit 的規則
1. 用一行空白區分 標題 和 內容
2. 標題限制在 50 個字以內
3. 標題要大寫
good
Accelerate to 88 miles per hour
Bad
accelerate to 88 miles per hour
4. 不要用 . 號
good
Open the pod bay doors
bad
Open the pod bay doors.
5. Use the imperative mood in the subject line
找一些字帶來代表這個 commit 要做的事情
範例
Refactor subsystem X for readability
Update getting started documentation
Remove deprecated methods
Release version 1.0.0
good
Refactor subsystem X for readability
Update getting started documentation
Remove deprecated methods
Release version 1.0.0
bad
Fixed bug with Y
Changing behavior of X
More fixes for broken stuff
Sweet new API methods
6. 內容限制在 72 個字以內
7. 用內容去解釋 what 和 why vs. how
commit訊息必須要有兩個部分
- Subject
- Body
Subject
簡短
訊息
50個字以內
提供這次commit的摘要
英文 | 意義 |
---|---|
feat (feature) | 新增 |
fix (bug fix) | 修正 |
docs (documentation) | 增加文件 |
style (formatting, missing semi colons, …) | 改變程式碼的排版 |
refactor | 重構 (remove code, fixes a bug nor adds a feature) |
test (when adding missing tests) | 增加測試(回報狀況) |
chore (maintain) | 苦功 (含蓋上面全部? 其它) |
Body
why the changes were made(為何這次的改變會產生)
what this changes are for(這次改變是為了什麼)
//範例
Add missing meta fields to response
in addition to the title and the text the status and created
columns are added to the response to be able to filter content
by status and date in the FE
See: TICKET-1234