在hook-post-commit中执行git命令

在hook-post-commit中执行git命令,git,shell,command,hook,post-commit,Git,Shell,Command,Hook,Post Commit,我有一个post-commit钩子。我想在我每次提交回购协议时计算提交数量。我写道: #!/bin/sh commit_number=$(git shortlog | grep -E '^[ ]+\w+' | wc -l) echo "$commit_number" 每次新提交,终端都会打印0。。。我不知道为什么。如果我在终端内提交后启动此命令,我的计数正确。尝试执行以下操作: cd .. commit_number=$(env -i git shortlog | grep -E '^[ ]+

我有一个post-commit钩子。我想在我每次提交回购协议时计算提交数量。我写道:

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

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

尝试执行以下操作:

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

谢谢!我是用git版本列表制作的。为什么shortlog不这么做?