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

后端 未结 9 1686
青春惊慌失措
青春惊慌失措 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条回答
  •  春和景丽
    2020-12-12 15:04

    How about

    git ls-files | xargs ls -l | sort -nrk5 | head -n 10
    
    • git ls-files: List all the files in the repo
    • xargs ls -l: perform ls -l on all the files returned in git ls-files
    • sort -nrk5: Numerically reverse sort the lines based on 5th column
    • head -n 10: Print the top 10 lines

提交回复
热议问题