【发布时间】:2017-08-18 06:14:49
【问题描述】:
我有一个本地预提交钩子,它执行,并在我运行时按预期停止提交
git commit
另外,正如预期的那样,我可以在运行git commit -n ...时绕过钩子
但是,运行 git commit -am "My message" 或者实际上只运行 git commit -a 似乎绕过了钩子并允许处理提交。
知道为什么会发生这种情况吗?
编辑:钩在下面。
PROJECT_ROOT=`git rev-parse --show-toplevel`
CHANGED=`git diff --stat -- $PROJECT_ROOT/myProj/myfile.ext | wc -l`
if [ $CHANGED -gt 0 ];
then
echo "myfile.ext file has changed, are you sure you want to commit"
echo "Use the -n parameter to process this commit."
exit 1
fi
【问题讨论】:
-
也粘贴钩子。
-
正如你写的那样,我意识到我的钩子条件可能对每个命令的评估不同.. :)