<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # git commit 提交規范 & 規范校驗 ## Git Log 之痛 在《The Art of Readable Code》這本經典書中,有個形象的比喻,衡量代碼可讀性的指標是閱讀代碼時每分鐘的 WTF 次數,而在讀 Git 提交歷史的時候,不知道你有多少次爆粗口?不相信?你現在打開公司演進最快的項目,執行 git log,信息量過少甚至是誤導的 commit message 非常常見,比如: ``` fix => 這到底是 fix 什么?為什么 fix?怎么 fix 的? update => 更新了什么?是為了解決什么問題? test => 這個最讓人崩潰,難道是為了測試?至于為了測試而去提交一次代碼么? ``` 說不定,你在這種 commit message 中也貢獻了一份力量呢。 ## 修改git message默認編輯器 說了這么多寫作規范,如果有個模板可以直接拷貝,是再好不過的。 可以把默認編輯器改成 vim: ``` git config –global core.editor vim ``` ## commit messages 模板 ``` curl https://gist.githubusercontent.com/keniushadu/5c7de811bfd77c4cd9c5cd981d401d0d/raw/e048f777bd690767c13544b63f936c1a3219da5e/commit-msg.txt >> ~/.git-commit-template.txt ``` 標準模板內容: ``` # Type(<scope>): <subject> # <body> # <footer> # type 字段包含: # feat:新功能(feature) # fix:修補bug # docs:文檔(documentation) # style: 格式(不影響代碼運行的變動) # refactor:重構(即不是新增功能,也不是修改bug的代碼變動) # test:增加測試 # chore:構建過程或輔助工具的變動 # scope用于說明 commit 影響的范圍,比如數據層、控制層、視圖層等等。 # subject是 commit 目的的簡短描述,不超過50個字符 # Body 部分是對本次 commit 的詳細描述,可以分成多行 # Footer用來關閉 Issue或以BREAKING CHANGE開頭,后面是對變動的描述、 # 以及變動理由和遷移方法 # 英文版詳細例子,請看這里 # https://github.com/sparkbox/how_to/tree/master/style/git # 中文版介紹,請看這里 # http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html ``` ``` git config --global commit.template ~/.git-commit-template.txt ``` ## 簡單模板內容 ``` 如 xxx_template文件,其內容如下: [需求/BUG]: [模塊]: [說明]: ``` ## 注意 a、`git commit` 之前先要使用 `git add` 將沒有入庫的代碼入庫 b、可以使用 `git add -a` 提交多個代碼文件 5、在 `git commit` 之后,會以設置的編輯器打開模板文件,然后按照格式修改該文件,并保存 > 與團隊成員約定做 git 提交時使用 `git commit`,不能直接用 `git commit -m` 跳過規范。 ## 規范校驗 在多人協作項目中,如果代碼風格統一、代碼提交信息的說明準確,那么在后期協作以及Bug處理時會更加方便。 因此,在本文章中,我會介紹怎么使用下面這個工具,在 `git push` 代碼之前檢測 `commit messages`: * [commitlint ](https://commitlint.js.org/) * husky # Refs [Semantic Release with Lerna and Conventional Commits](https://michaljanaszek.com/blog/lerna-conventional-commits) [GitHub中使用 issues 模版和 pull request 模版](https://www.jianshu.com/p/39e7e3c0a43f) [About issue and pull request templates](https://help.github.com/en/articles/about-issue-and-pull-request-templates) [Commit message 和 Change log 編寫指南](http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html) [你可能已經忽略的git commit規范](https://zhuanlan.zhihu.com/p/100574040)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看