2012-12-04 56 views
1

是否有可能改變部分:提交時是否可以更改Git標準消息?

# Please enter the commit message for your changes. Lines starting 
# with '#' will be ignored, and an empty message aborts the commit. 
# On branch master 
# Changes to be committed: 

地說:

# Staged: 
+0

可能重複:HTTP://計算器。 com/questions/3966714/how-can-i-change-the-default-comments-in-the-git-commit-message –

+0

你爲什麼要這樣做? – asmeurer

回答

5

是的,使用prepare-commit-msg鉤子。這是一個.git/hooks/中的腳本,它在Git的提交消息生成和編輯器中打開的提交消息之間運行。

舉一個簡單的例子,將下面的文本複製到.git/hooks/中的一個名爲prepare-commit-msg的新文件中。

#!/bin/sh 
sed -i '0,/# Changes to be committed:/c# Staged:' "$1" 

如果你發現它並沒有立即開展工作,檢查它的可執行文件:運行chmod +x .git/hooks/prepare-commit-msg

(腳本是sed的一行替換每一行直至幷包括了「變更,必須致力於」與文本行「#上演」)

0

在一個簡單的方法,只是一部分,沒有。

但是你可以使用commit-msg鉤子修改提交信息。

相關問題