markdown 一些命令在命令行上获取存储库的git commit日志统计信息。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 一些命令在命令行上获取存储库的git commit日志统计信息。相关的知识,希望对你有一定的参考价值。
git commit stats
================
Commands to get commit statistics for a Git repository from the command line -
using `git log`, `git shortlog` and friends.
<br>
<hr>
<br>
### List repository contributors by author name (sorted by name):
```sh
$ git log --format='%aN' | sort -u
```
**Example output:**
Jane Bar
John Foo
Steve Baz
<br>
<hr>
<br>
### List total commits by author (sorted by commit count):
```sh
$ git shortlog -sn
```
**Example output:**
136 Jane Bar
41 John Foo
17 Steve Baz
#### Ignore merge commits:
```sh
$ git shortlog -sn --no-merges
```
**Example output:**
121 Jane Bar
36 John Foo
14 Steve Baz
*Even though the `--no-merges` option is not documented for `git shortlog`, it works exactly as defined for `git log`.*
<br>
<hr>
<br>
### List file change stats by author:
```sh
$ git log --author="Vorname Nachname" --pretty=tformat: --numstat | awk '{inserted+=$1; deleted+=$2; delta+=$1-$2; ratio=deleted/inserted} END {printf "Commit stats:\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", inserted, deleted, delta, ratio }' -
```
**Example output:**
Commit stats:
- Lines added (total).... 4625
- Lines deleted (total).. 836
- Total lines (delta).... 3789
- Add./Del. ratio (1:n).. 1 : 0.180757
#### Include file count:
```sh
$ git log --shortstat --author="Vorname Nachname" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6; delta+=$4-$6; ratio=deleted/inserted} END {printf "Commit stats:\n- Files changed (total).. %s\n- Lines added (total).... %s\n- Lines deleted (total).. %s\n- Total lines (delta).... %s\n- Add./Del. ratio (1:n).. 1 : %s\n", files, inserted, deleted, delta, ratio }' -
```
**Example output:**
Commit stats:
- Files changed (total).. 439
- Lines added (total).... 4625
- Lines deleted (total).. 836
- Total lines (delta).... 3789
- Add./Del. ratio (1:n).. 1 : 0.180757
#### Ignore merge commits:
Note: Both commands above also count merge commits. But to ignore them, one can simply use the `--no-merges` option again:
```sh
$ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ...
# or
$ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ...
```
#### Filter stats by date:
You can filter the output of the above commands, for example, by adding `--until` or `--since` or `--before`:
```sh
$ git log --author="Vorname Nachname" --pretty=tformat: --numstat --since="1 Jan, 2015" | awk ...
# or
$ git log --shortstat --author="Vorname Nachname" --since="1 Jan, 2015" | grep -E ...
```
<br>
<hr>
<br>
<br><br><br>
以上是关于markdown 一些命令在命令行上获取存储库的git commit日志统计信息。的主要内容,如果未能解决你的问题,请参考以下文章
在命令行上获取当前年份[重复]
Laravel env() 或 config() 在命令行上获取环境变量
在命令行上获取用户输入。
如何在 Windows 命令行上获取一组文件的最后修改日期?
在命令行上完成机器人测试后如何获取退出代码或退出状态
在 Perl 中,如何在命令行上发送 CGI 参数?