欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

git如何查看提交行數(shù)、刪除行數(shù)

 更新時間:2025年05月26日 08:37:44   作者:Fu_Lin_  
這篇文章主要介紹了git如何查看提交行數(shù)、刪除行數(shù)問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

統(tǒng)計指定用戶提交代碼情況

git log --author="你的名字" --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 }' -

統(tǒng)計每個人的代碼提交情況

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

在指定時間范圍內(nèi)查詢

新增字段修改時間since和until

git log  --author="xxxx" --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat:  --since ==2023-6-1 --until=2024-1-1 --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

參數(shù)說明

git log 參數(shù)說明:
--author   指定作者
--stat   顯示每次更新的文件修改統(tǒng)計信息,會列出具體文件列表
--shortstat    統(tǒng)計每個commit 的文件修改行數(shù),包括增加,刪除,但不列出文件列表:  
--numstat   統(tǒng)計每個commit 的文件修改行數(shù),包括增加,刪除,并列出文件列表:
 
   
-p 選項展開顯示每次提交的內(nèi)容差異,用 -2 則僅顯示最近的兩次更新
       例如:git log -p  -2
--name-only 僅在提交信息后顯示已修改的文件清單
--name-status 顯示新增、修改、刪除的文件清單
--abbrev-commit 僅顯示 SHA-1 的前幾個字符,而非所有的 40 個字符
--relative-date 使用較短的相對時間顯示(比如,“2 weeks ago”)
--graph 顯示 ASCII 圖形表示的分支合并歷史
--pretty 使用其他格式顯示歷史提交信息??捎玫倪x項包括 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 僅顯示指定作者相關(guān)的提交。                
       --committer 僅顯示指定提交者相關(guān)的提交。

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論