2012-03-22 73 views
0

可能重複:
How can I change the default comments in the git commit message?git:如何取消註釋默認提交消息文本?

默認的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: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# modified: file1 
# modified: file2 
# 

這是對我很好。但默認情況下,我寧願有一些行註釋掉:

# 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: 
# (use "git reset HEAD <file>..." to unstage) 

    modified: file1 
    modified: file2 
# 

所以我不必每次都取消其註釋。 這可能嗎?

謝謝

+4

爲什麼你想在提交消息中的修改文件列表?這是完全多餘的。 – 2012-03-22 21:31:07

+0

這不是一個重複的問題。海報特別希望在提交信息中包括修改文件的列表,而另一個問題根本沒有提及。 – amcnabb 2012-03-23 00:17:55

回答

1

這個信息很容易生成。不要在提交消息中包含這些信息,因爲它所能做的只是與提交中的實際更改不同步。相反,讓git稍後生成你需要的信息。例如,git log --name-status將顯示哪些文件被修改。您甚至可以在您的.gitconfig中設置alias以使此類選項成爲默認值。這種方法應該爲您提供所需的所有信息,同時避免可能的陷阱和違規的git慣例。