Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding most changed files in Git

Tags:

git

shell

People also ask

How do you find a list of files that has changed in a particular commit?

Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.

How do I see revision history in git?

Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.


You could do something like the following:

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

The log just outputs the names of the files that have been changed in each commit, while the rest of it just sorts and outputs the top 10 most frequently appearing filenames.


you can use the git effort (from the git-extras package) command which shows statistics about how many commits per files (by commits 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.


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

Old question, but I think still a very useful question. Here is a working example in straight powershell. This will get the top 10 most changed files in your repo with respect to the branch you are on.

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