日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【git学习】统计git项目某user的代码量

發布時間:2023/12/10 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【git学习】统计git项目某user的代码量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?查看自己的代碼量:(直接awk編程)

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 }' -

輸出結果:?

其他操作:

統計每個人的增刪行數

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

?代碼總行數:

find . "(" -name "*.cc" ")" -print | xargs wc -l

查看倉庫提交者排名前 5

git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5
貢獻者統計:

git log --pretty='%aN' | sort -u | wc -l
提交數統計:

git log --oneline | wc -l

統計代碼總行數:
find . -name "*.m" -or -name "*.h" -or -name "*.xib" -or -name "*.c" |xargs grep -v "^$"|wc -l

或者

find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.rss" ")" -print | xargs wc -l

等等

參數說明:

git log 參數說明:
–author 指定作者
–stat 顯示每次更新的文件修改統計信息,會列出具體文件列表
–shortstat 統計每個commit 的文件修改行數,包括增加,刪除,但不列出文件列表:
–numstat 統計每個commit 的文件修改行數,包括增加,刪除,并列出文件列表:
-p 選項展開顯示每次提交的內容差異,用 -2 則僅顯示最近的兩次更新
例如:git log -p -2
–name-only 僅在提交信息后顯示已修改的文件清單
–name-status 顯示新增、修改、刪除的文件清單
–abbrev-commit 僅顯示 SHA-1 的前幾個字符,而非所有的 40 個字符
–relative-date 使用較短的相對時間顯示(比如,“2 weeks ago”)
–graph 顯示 ASCII 圖形表示的分支合并歷史
–pretty 使用其他格式顯示歷史提交信息。可用的選項包括 oneline,short,full,fuller 和 format(后跟指定格式)
例如: git log --pretty=oneline ; git log --pretty=short ; git log --pretty=full ; git log --pretty=fuller
–pretty=tformat: 可以定制要顯示的記錄格式,這樣的輸出便于后期編程提取分析
例如:git log --pretty=format:""%h - %an, %ar : %s""
下面列出了常用的格式占位符寫法及其代表的意義。
選項 說明
%H 提交對象(commit)的完整哈希字串
%h 提交對象的簡短哈希字串
%T 樹對象(tree)的完整哈希字串
%t 樹對象的簡短哈希字串
%P 父對象(parent)的完整哈希字串
%p 父對象的簡短哈希字串
%an 作者(author)的名字
%ae 作者的電子郵件地址
%ad 作者修訂日期(可以用 -date= 選項定制格式)
%ar 作者修訂日期,按多久以前的方式顯示
%cn 提交者(committer)的名字
%ce 提交者的電子郵件地址
%cd 提交日期
%cr 提交日期,按多久以前的方式顯示
%s 提交說明
–since 限制顯示輸出的范圍,
例如: git log --since=2.weeks 顯示最近兩周的提交
選項 說明
-(n) 僅顯示最近的 n 條提交
–since, --after 僅顯示指定時間之后的提交。
–until, --before 僅顯示指定時間之前的提交。
–author 僅顯示指定作者相關的提交。
–committer 僅顯示指定提交者相關的提交。

一些例子:

git log --until=1.minute.ago // 一分鐘之前的所有 log

git log --since=1.day.ago //一天之內的log

git log --since=1.hour.ago //一個小時之內的 log

git log --since=`.month.ago --until=2.weeks.ago //一個月之前到半個月之前的log

git?log --since ==2013-08.01 --until=2013-09-07 //某個時間段的 log git blame
看看某一個文件的相關歷史記錄
例如:git blame index.html --date short

參考鏈接:

https://blog.csdn.net/congqingbin/article/details/78547996?

總結

以上是生活随笔為你收集整理的【git学习】统计git项目某user的代码量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。