How to find the N largest files in a git repository?

后端 未结 9 1697
青春惊慌失措
青春惊慌失措 2020-12-12 14:33

I wanted to find the 10 largest files in my repository. The script I came up with is as follows:

REP_HOME_DIR=
max_huge_files=         


        
9条回答
  •  Happy的楠姐
    2020-12-12 14:50

    Cannot comment. ypid's answer modified for powershell

    git ls-tree -r -l --abbrev --full-name HEAD | Sort-Object {[int]($_ -split "\s+")[3]} | Select-Object -last 10
    

    Edit raphinesse's solution(ish)

    git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | Where-Object {$_ -like "blob*"} | Sort-Object {[int]($_ -split "\s+")[2]} | Select-Object -last 10
    

提交回复
热议问题