簡體   English   中英

在git中添加提交時是否可以更改提交消息的注釋部分的內容?

[英]Is it possible to change the contents of the commentted part of the commit message when adding a commit in git?

我不想更改實際的提交消息,我想在輸入提交消息時更改顯示的注釋文本的模板。

例如:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch add_mssql
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   csv/jobdetails.csv
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   db/test.db
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       Person.js
#       README.MD
#       get_supervisorjobs.js
#       loadmsqlviews.js
#       mssql/
#       results.html
#       results.js
#       supervisorsNpositions.js

您可以使用git config --global commit.template ~/.gitmessage.txt 更改默認提交消息模板 git config --global commit.template ~/.gitmessage.txt (只需確保你有一個.gitmessage.txt文件,並且內容是你想要的默認內容。)

更改默認提交消息的另一種方法是安裝prepare-commit-msg git hook。 這允許您提供腳本以根據情況以不同方式修改提交消息(無論是新提交,合並提交和修改提交等)。

請參閱git hooks --help下的prepare-commit-msg。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM