Finding most changed files in Git

前端 未结 9 1652
野的像风
野的像风 2020-11-29 15:24

How can I show files in Git which change most often?

相关标签:
9条回答
  • 2020-11-29 15:56
    git whatchanged --all | \grep "\.\.\." | cut -d' ' -f5- | cut -f2- | sort | uniq -c | sort
    

    If you only want to see your files add --author to git whatchanged --author=name --all.

    0 讨论(0)
  • 2020-11-29 15:59

    I noticed that both Mark’s and sehe’s answers do not --follow the files, that is to say they stop once they reach a file rename. This script will be much slower, but will work for that purpose.

    git ls-files |
    while read aa
    do
      printf . >&2
      set $(git log --follow --oneline "$aa" | wc)
      printf '%s\t%s\n' $1 "$aa"
    done > bb
    echo
    sort -nr bb
    rm bb
    

    git-most.sh

    0 讨论(0)
  • 2020-11-29 16:03

    This is a windows version

    git log --pretty=format: --name-only  > allfiles.csv
    

    then open in excel

    A1: FileName
    A2: isVisibleFilename  >> =IFERROR(IF(C2>0,TRUE,FALSE),FALSE)
    A3: DotLocation >> =FIND("@",SUBSTITUTE(A2,".","@",(LEN(A2)-LEN(SUBSTITUTE(A2,".","")))/LEN(".")))
    A4: HasExt       >> =C2>1
    A5: TYPE        >> =IF(D2=TRUE,MID(A2,C2+1,18),"")
    

    create pivot table

    values: Type
      Filter: isFilename = true
      Rows : Type
      Sub : FileName
    
    click [Count Of TYPE] -> Sort -> Sort Largest To Smallest
    
    0 讨论(0)
  • 2020-11-29 16:07

    This is probably obvious, but, the queries provided will show all files, but, perhaps you're not interested in knowing that your configuration or project files are the most updated. A simple grep will isolate to your code files, for example:

    git log --pretty=format: --name-only | grep .cs$ | sort | uniq -c | sort -rg | head -20
    
    0 讨论(0)
  • 2020-11-29 16:09

    For powershell, assuming you got git bash installed

    git log --pretty=format: --name-only | sort | uniq -c | sort -Descending | select -First 10
    
    0 讨论(0)
  • 2020-11-29 16:09

    We can also find out files changed between two commits or branches, for e.g.

    git log  --pretty=format: --name-only <source_branch>...<target_branch> | sort | uniq -c | sort -rg | head -50 
    
    0 讨论(0)
提交回复
热议问题