我有一个提交后挂钩。我想在每次交易我的回购时计算提交号。我写道:
#!/bin/sh
commit_number=$(git shortlog | grep -E '^[ ]+\w+' | wc -l)
echo "$commit_number"
每次新提交,终端都打印0 ...我不知道为什么。如果我在终端内提交后启动此命令,我的计数正确。
答案 0 :(得分:0)
尝试做类似的事情:
cd ..
commit_number=$(env -i git shortlog | grep -E '^[ ]+\w+' | wc -l)
echo "$commit_number"