在hook post-commit中执行git命令

时间:2013-02-21 14:58:54

标签: git shell command hook post-commit

我有一个提交后挂钩。我想在每次交易我的回购时计算提交号。我写道:

#!/bin/sh
commit_number=$(git shortlog | grep -E '^[ ]+\w+' | wc -l)
echo "$commit_number"

每次新提交,终端都打印0 ...我不知道为什么。如果我在终端内提交后启动此命令,我的计数正确。

1 个答案:

答案 0 :(得分:0)

尝试做类似的事情:

cd ..
commit_number=$(env -i git shortlog | grep -E '^[ ]+\w+' | wc -l)
echo "$commit_number"