统计个人增删行数
代码语言:javascript复制git config user.name
git log --author="zhaoyifan" --pretty=tformat: --numstat | awk '{ add = $1; subs = $2; loc = $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %sn", add, subs, loc }' -
代码语言:javascript复制added lines: 82813, removed lines: 53707, total lines: 29106
统计每个人增删行数
代码语言:javascript复制git log --shortstat | grep -E "(Author: )(s*(w )){2}|fil(e|es) changed" | awk '
{
if($1 ~ /Author/) {
author = $2" "$3
} else {
files[author] =$1
inserted[author] =$4
deleted[author] =$6
}
}
END { for (key in files) { print "Author: " key "ntfiles changed: ", files[key], "ntlines inserted: ", inserted[key], "ntlines deleted: ", deleted[key] } }
'
统计每个人提交次数
代码语言:javascript复制git shortlog -sn --no-merges
忽略某些路径的更改
代码语言:javascript复制git log -- . ":(exclude)sub"
git log -- . ":!sub"
cloc
AlDanial/cloc - cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
代码语言:javascript复制cloc source/
186 text files.
186 unique files.
3 files ignored.
github.com/AlDanial/cloc v 1.84 T=0.16 s (1112.3 files/s, 138678.8 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Markdown 183 6028 0 16788
-------------------------------------------------------------------------------
SUM: 183 6028 0 16788
-------------------------------------------------------------------------------
Git Fame
Git Fame - A command-line tool that helps you summarize and pretty-print git collaborators based on contributions
代码语言:javascript复制gem install git_fame
cd /path/to/gitdir && git fame
Total number of files: 2,053
Total number of lines: 63,132
Total number of commits: 4,330
------------------------ -------- --------- ------- --------------------
| name | loc | commits | files | percent |
------------------------ -------- --------- ------- --------------------
| Johan Sørensen | 22,272 | 1,814 | 414 | 35.3 / 41.9 / 20.2 |
| Marius Mathiesen | 10,387 | 502 | 229 | 16.5 / 11.6 / 11.2 |
| Jesper Josefsson | 9,689 | 519 | 191 | 15.3 / 12.0 / 9.3 |
| Ole Martin Kristiansen | 6,632 | 24 | 60 | 10.5 / 0.6 / 2.9 |
| Linus Oleander | 5,769 | 705 | 277 | 9.1 / 16.3 / 13.5 |
| Fabio Akita | 2,122 | 24 | 60 | 3.4 / 0.6 / 2.9 |
| August Lilleaas | 1,572 | 123 | 63 | 2.5 / 2.8 / 3.1 |
| David A. Cuadrado | 731 | 111 | 35 | 1.2 / 2.6 / 1.7 |
| Jonas Ängeslevä | 705 | 148 | 51 | 1.1 / 3.4 / 2.5 |
| Diego Algorta | 650 | 6 | 5 | 1.0 / 0.1 / 0.2 |
| Arash Rouhani | 629 | 95 | 31 | 1.0 / 2.2 / 1.5 |
| Sofia Larsson | 595 | 70 | 77 | 0.9 / 1.6 / 3.8 |
| Tor Arne Vestbø | 527 | 51 | 97 | 0.8 / 1.2 / 4.7 |
| spontus | 339 | 18 | 42 | 0.5 / 0.4 / 2.0 |
| Pontus | 225 | 49 | 34 | 0.4 / 1.1 / 1.7 |
------------------------ -------- --------- ------- --------------------
让 git log 的输出漂亮简洁
代码语言:javascript复制git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an �>%Creset' --abbrev-commit"
https://gist.github.com/johanmeiring/3002458
在 ~/.gitconfig
看到:
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an �>%Creset' --abbrev-commit
这其中的占位符的解释:
- %Cred:将颜色设置为红色
- %Creset:重置颜色
- %C(yellow):将颜色设置为黄色
- %h:缩略的提交哈希值
- %d:ref names(不知道该怎么解释