--- title: Tips to commit tags: Git --- # Commit Tips ## Recommend - 在任何 commit 之前最好先做一次 pre-commit, 用來初步檢查簡單的安全漏洞, 命名規則, 縮排以及 coding style 等, 現成的工具有 husky - gitlab 可以建立 `.pre-commit-config.yaml` 來個別實現 - 建議實作 global pre-commit 和 project-based pre-commit - 善用環境變數取代敏感內容 - post-commit 可以用來生成提示訊息, 要注意的是這裡已經完成 commit ## Recommend of commit - Imperative - First alphabet never be uppercase - Without punctuation at trailing end ## Composition of commit - type: commit type - scope: commit 牽涉的範圍 - subject: concise digest - body: detailed imperatives - footer: related issues ## Type Example feat: 加入新功能 fix: 修改 bug docs: 修改檔案 style: 空格, 縮排等不影響程式主體的修正 refactor: 重構程式碼, 不影響程式主體的修正 perf: performance test, 例如輸出時間, 記憶體用量等 test: 增加測試的例子, 例如輸出 log, 撰寫 ut 等 chore: 更改流程, 引入 library 等 # Reference http://josephlin.org/git-styleguide.html