doc: update git.md (#216)

This commit is contained in:
fw_qaq 2022-12-07 21:46:31 +08:00 committed by GitHub
parent 403838287e
commit 7348140ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -960,6 +960,41 @@ Host github.com
```
<!--rehype:className=wrap-text-->
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
----