title: Git项目管理
date: 2013-01-07 10:51:37
categories:
git log --author="_your_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 }'
git log --author=xxxxx --since=‘2023-01-18 00:00:00’ --until=‘2023-01-18 23:00:00’ --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 }’
git log 查询git的提交记录
–author=xxx 查询某一个用户的提交记录
–pretty=tformat: 控制显示的记录格式
–numstat 对增加和删除的行数进行统计 第一列显示的是增加的行数 第二列显示的是删除的行数
–since 需要统计的开始时间
–until 需要统计的结束时间
实操:
常量形式
git log --author="qian" --since='2023-02-18 00:00:00' --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 }'
变量形式
authorName=qian
sincedate='2023-02-18 00:00:00'
git log --author="$authorName" --since="$sincedate" --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 }'
增加统计多少个文件
git log --author="$authorName" --since="$sincedate" --pretty=tformat: --numstat | awk '/./ { add += $1; subs += $2; loc += $1 - $2 } END { printf "modified files: %s, added lines: %s, removed lines: %s, total lines: %s\n", NR, add, subs, loc }'