設定 Git Commit 預設的 Template

Git Commit 的時候,都會規範一些格式,例如:[Add / Update / Fix][issue #id] Reason... 等等。

能不能每次 Commit 的時候,自動將標準格式的 Template 帶入呢?

設定 Git Commit 預設的 Template

設定 Git commit 的時候,預設的 Template,步驟如下:(取自此篇:Git. Write quality commits. - DEV)

  1. $ vim ~/.git-commit-template # 下面是 template,可自行修改
    #[Add/Fix/Remove/Update/Refactor/Document/Secure/Deprecate]
    #[]
    
    # Why is it necessary? (Bug fix, feature, improvements?)
    #-
    
    # [issue #id]
  2. cd ~/project
  3. git config commit.template /home/user/.git-commit-template
  4. cat ~/project/.git/config # 會有下述
    [commit]
        template = /home/user/.git-commit-template
  5. git commit # 進入 commit 畫面就會有註解起來的 template 可以使用

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料