Git准备提交消息

Git准备提交消息,git,git-commit,githooks,Git,Git Commit,Githooks,我的代码: COMMIT\u MSG\u文件=$1 提交源=$2 SHA1=3美元 git diff--cached--name status>/.git/test.txt git var git|u提交人|sed-n的/^\(.*>\).$/签字人:\1/p'>>。git/test.txt SOB=$(cat.git/test.txt) git解释预告片--就地--预告片“$SOB”$COMMIT\u MSG\u文件” 我试图在git commit消息的末尾获得git diff--cache

我的代码:

COMMIT\u MSG\u文件=$1
提交源=$2
SHA1=3美元
git diff--cached--name status>/.git/test.txt
git var git|u提交人|sed-n的/^\(.*>\).$/签字人:\1/p'>>。git/test.txt
SOB=$(cat.git/test.txt)
git解释预告片--就地--预告片“$SOB”$COMMIT\u MSG\u文件”
我试图在git commit消息的末尾获得git diff--cached--name status的输出,这是可行的,但奇怪的是如果我使用git commit,然后关闭文件(commit_EDITMSG)提交将被提交,但如果我在
git diff--cached--name status>/.git/test.txt
中做了注释,那么提交可以通过不编辑文件而中止,这就是我试图修复的,但似乎我无法提供任何建议

示例输出为:

M   README.md
Signed-off-by: NAME \<E-Mail\>
M README.md
签字人:姓名\