#!/bin/bash
# 初始化总提交次数和总提交行数
total_commits=0
total_lines=0
# 遍历所有的分支
for branch in $(git branch -r | grep -v HEAD);do
echo "Checking branch $branch"
# 检出到当前分支
git checkout $branch > /dev/null 2>&1
# 统计当前分支的提交次数
commits=$(git log --author=doufangyu --oneline | wc -l)
echo "Commits in $branch: $commits"
total_commits=$((total_commits + commits))
# 统计当前分支的提交行数
lines=$(git log --author=doufangyu --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { print loc }')
echo "Lines in $branch: $lines"
total_lines=$((total_lines + lines))
done
# 输出总提交次数和总提交行数
echo "Total commits by doufangyu: $total_commits"
echo "Total lines by doufangyu: $total_lines"
02-07
825
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-09
800
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-26