Git/日志:修订间差异

来自康健生活
< Git
Kangkk​(留言 | 贡献)
创建页面,内容为“ == log == === 查找人 === 查找单人。 {{shc|<syntaxhighlight lang="bash"> git log --online --author="kangjian"</syntaxhighlight>|$|/home/kangkk}} 查找多人。 {{shc|<syntaxhighlight lang="bash"> git log --online --author="kangjian\|lanqian"</syntaxhighlight>|$|/home/kangkk}} === 查找关键字 === {{shc|<syntaxhighlight lang="bash"> git log --online --grep="kangkk"</syntaxhighlight>|$|/home/kangkk}} === 查找文件内容信息 === {{shc|<syntaxhi…”
 
Kangkk​(留言 | 贡献)
无编辑摘要
第34行: 第34行:
{{shc|<syntaxhighlight lang="bash">
{{shc|<syntaxhighlight lang="bash">
git reflog</syntaxhighlight>|$|/home/kangkk}}
git reflog</syntaxhighlight>|$|/home/kangkk}}
== 统计 ==
=== 个人代码提交量 ===
{{Shc_out|<syntaxhighlight lang="bash">
git log --author="kangjian" --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 }' -
</syntaxhighlight>|<syntaxhighlight lang="bash">
added lines: 170168, removed lines: 51562, total lines: 118606
</syntaxhighlight>|$|/home/kangkk}}
个人代码提交,附带时间区间。
{{Shc_out|<syntaxhighlight lang="bash">
git log --author=kangjian --since=2021-02-01 --until=2022-02-01 --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | grep "\(.html\|.java\|.xml\|.properties\)$" | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done</syntaxhighlight>|<syntaxhighlight lang="bash">
kangjian added lines: 94, removed lines: 16, total lines: 78
</syntaxhighlight>|$|/home/kangkk}}
=== 增删代码量 ===
{{Shc_out|<syntaxhighlight lang="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</syntaxhighlight>|<syntaxhighlight lang="bash">
cuili added lines: 19476, removed lines: 105928, total lines: -86452
heweixiao added lines: 3371, removed lines: 1532, total lines: 1839
kangjian added lines: 4571, removed lines: 1215950, total lines: -1211379
liuguanyu added lines: 1777938, removed lines: 106, total lines: 1777832
xuke5 added lines: 42708, removed lines: 590, total lines: 42118
</syntaxhighlight>|$|/home/kangkk}}
=== 总代码行数 ===
{{Shc_out|<syntaxhighlight lang="bash">
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | grep "\(.html\|.java\|.xml\|.properties\|.css\|.js\|.txt\)$" | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done</syntaxhighlight>|<syntaxhighlight lang="bash">
chenyiwen added lines: 32, removed lines: 19, total lines: 13
kangjian added lines: 9978, removed lines: 7263, total lines: 2715
kangkk added lines: 44189, removed lines: 37408, total lines: 6781
lizheming added lines: 14833, removed lines: 5913, total lines: 8920
shuliqi added lines: , removed lines: , total lines:
wwenj added lines: 400, removed lines: 167, total lines: 233
yangyalin added lines: 286, removed lines: 138, total lines: 148
yangyalin1 added lines: 286, removed lines: 138, total lines: 148
yuyang7 added lines: 3926, removed lines: 1299, total lines: 2627
zhaowenbo added lines: 2396, removed lines: 432, total lines: 1964
康健 added lines: 8661, removed lines: 6907, total lines: 1754
</syntaxhighlight>|$|/home/kangkk}}
=== 贡献值统计 ===
{{Shc_out|<syntaxhighlight lang="bash">
git log --pretty='%aN' | sort -u | wc -l</syntaxhighlight>|<syntaxhighlight lang="bash">
      5
</syntaxhighlight>|$|/home/kangkk}}
=== 提交数统计 ===
{{Shc_out|<syntaxhighlight lang="bash">
git log --oneline | wc -l</syntaxhighlight>|<syntaxhighlight lang="bash">
    411
</syntaxhighlight>|$|/home/kangkk}}
=== 统计或修改的行数 ===
{{Shc_out|<syntaxhighlight lang="bash">
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'
</syntaxhighlight>|<syntaxhighlight lang="bash">
1848029
</syntaxhighlight>|$|/home/kangkk}}
== 提交次数排名 ==
{{Shc_out|<syntaxhighlight lang="bash">
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5</syntaxhighlight>|<syntaxhighlight lang="bash">
160 kangjian
  93 cuili
  61 liuguanyu
  56 heweixiao
  41 xuke5
</syntaxhighlight>|$|/home/kangkk}}
=== 统计或修改的行数 ===
{{Shc_out|<syntaxhighlight lang="bash">
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'</syntaxhighlight>|<syntaxhighlight lang="bash">
257528
</syntaxhighlight>|$|/home/kangkk}}

2024年2月29日 (四) 11:05的版本

log

查找人

查找单人。

/home/kangkk
git log --online --author="kangjian"

查找多人。

/home/kangkk
git log --online --author="kangjian\|lanqian"

查找关键字

/home/kangkk
git log --online --grep="kangkk"

查找文件内容信息

/home/kangkk
git log -S "75cdn"

查找时间区间

查找自2021年2月24日以后,早上10点到下午8点的记录。

/home/kangkk
git log --online --since="10am" --until="8pm" --after="2021-02-24"

查看文件

/home/kangkk
git log src/a.js

查看文件改动记录。

/home/kangkk
git log -p src/a.js

reflog

/home/kangkk
git reflog


统计

个人代码提交量

[jian@kang /home/kangkk]$
git log --author="kangjian" --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 }' -
added lines: 170168, removed lines: 51562, total lines: 118606

个人代码提交,附带时间区间。

[jian@kang /home/kangkk]$
git log --author=kangjian --since=2021-02-01 --until=2022-02-01 --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | grep "\(.html\|.java\|.xml\|.properties\)$" | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
kangjian	added lines: 94, removed lines: 16, total lines: 78

增删代码量

[jian@kang /home/kangkk]$
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
cuili	added lines: 19476, removed lines: 105928, total lines: -86452
heweixiao	added lines: 3371, removed lines: 1532, total lines: 1839
kangjian	added lines: 4571, removed lines: 1215950, total lines: -1211379
liuguanyu	added lines: 1777938, removed lines: 106, total lines: 1777832
xuke5	added lines: 42708, removed lines: 590, total lines: 42118

总代码行数

[jian@kang /home/kangkk]$
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | grep "\(.html\|.java\|.xml\|.properties\|.css\|.js\|.txt\)$" | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
chenyiwen	added lines: 32, removed lines: 19, total lines: 13
kangjian	added lines: 9978, removed lines: 7263, total lines: 2715
kangkk	added lines: 44189, removed lines: 37408, total lines: 6781
lizheming	added lines: 14833, removed lines: 5913, total lines: 8920
shuliqi	added lines: , removed lines: , total lines:
wwenj	added lines: 400, removed lines: 167, total lines: 233
yangyalin	added lines: 286, removed lines: 138, total lines: 148
yangyalin1	added lines: 286, removed lines: 138, total lines: 148
yuyang7	added lines: 3926, removed lines: 1299, total lines: 2627
zhaowenbo	added lines: 2396, removed lines: 432, total lines: 1964
康健	added lines: 8661, removed lines: 6907, total lines: 1754

贡献值统计

[jian@kang /home/kangkk]$
git log --pretty='%aN' | sort -u | wc -l
       5

提交数统计

[jian@kang /home/kangkk]$
git log --oneline | wc -l
     411

统计或修改的行数

[jian@kang /home/kangkk]$
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'
1848029

提交次数排名

[jian@kang /home/kangkk]$
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5
 160 kangjian
  93 cuili
  61 liuguanyu
  56 heweixiao
  41 xuke5

统计或修改的行数

[jian@kang /home/kangkk]$
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'
257528