From 7348140ae1969b3cdafd34d5396ad449c7ae5656 Mon Sep 17 00:00:00 2001 From: fw_qaq <82551626+fwqaaq@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:46:31 +0800 Subject: [PATCH] doc: update git.md (#216) --- docs/git.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/git.md b/docs/git.md index 86860c9..74f11ee 100644 --- a/docs/git.md +++ b/docs/git.md @@ -960,6 +960,41 @@ Host github.com ``` +git 代码统计 +--- + +### 查看 git 上的个人代码量 + +- `username` 需要改成自己的 + +```bash +git log --author="username" --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 }' - +``` + +### 统计每个人增删行数 + +```bash +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 +``` + +### 查看仓库提交者排名 + +这里是排名前十,也可以更改排名 + +```bash +git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 10 +``` + +### 提交数统计 + +```bash +git log --oneline | wc -l +``` + Conventional Commmits ----