Finding Most Modified Files in Git

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

+83
git shell
07 Oct '11 at 11:25
source share
9 answers

you can use the git effort command (from the git-extras package), which shows statistics on how many commits per file (for fixed and active days).

EDIT: git effort is just a bash script you can find here and adapt to your needs if you need something more special.

+36
Feb 05 '16 at 13:11
source share

You can do something like the following:

 git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -10 

The log simply displays the names of the files that were changed in each commit, and the rest simply sorts and displays the 10 most common file names.

+119
Oct 07 '11 at 11:29
source share

I noticed that both Marx and sehes answers are not --follow files, that is, they stop as soon as they reach the file rename. This script will be much slower, but will work for this 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

+11
Dec 27 '13 at 21:45
source share

For powershell if you installed git bash

 git log --pretty=format: --name-only | sort | uniq -c | sort -Descending | select -First 10 
+3
Aug 28 '13 at 15:38
source share

This is a version of Windows.

 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 
+3
Nov 18 '15 at 15:44
source share
 git whatchanged --all | \grep "\.\.\." | cut -d' ' -f5- | cut -f2- | sort | uniq -c | sort 

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

+2
Jul 03 '14 at 14:20
source share

We can also find files modified between two commits or branches, for example,

 git log --pretty=format: --name-only <source_branch>...<target_branch> | sort | uniq -c | sort -rg | head -50 
0
Oct 08
source share

This is probably obvious, but the submitted requests will show all the files, but you may not be interested to know that your configuration or project files are most updated. Simple grep will isolate your code files, for example:

 git log --pretty=format: --name-only | grep .cs$ | sort | uniq -c | sort -rg | head -20 
0
Nov 11 '13 at 18:00
source share

Old question, but I think it is still a very useful question. Here is a working example in simple PowerShell. This will give the 10 most modified files in your repo relative to the branch you are in.

 git log --pretty=format: --name-only | Where-Object { ![string]::IsNullOrEmpty($_) } | Sort-Object | Group-Object | Sort-Object -Property Count -Descending | Select-Object -Property Count, Name -First 10 
0
May 03 '19 at 17:18
source share



All Articles