我想计算 git 存储库中每个提交者的总行数。我只得到以下解决方案:
git log --format='%aN' | sort -u | \
while read name; do
echo -en "$name\t"
git log --author="$name" --pretty=tformat: --numstat | \
awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
done
它可以计算出每个提交者的总行数的所有历史记录。但我想在当前快照中计算出每个提交者的总行数。我不知道该怎么做。
您有解决这个问题的方法吗?
最佳答案
这有点过大而且缓慢,但你可以这样做。
git log --format='%aN' | sort -u | \
while read name; do
echo -en "$name\t"
for FILE in $(git ls-files) ; do git blame $FILE | grep "$name" ; done | wc -l
done
关于git - 如何统计 git 存储库中每个提交者的总行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53624905/