Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find most heavily edited file in git commit

Tags:

git

github

Say I make a commit to a git repository with a lot of files changed.

How can I find out which file got changed the most in this specific commit? (the most lines of code changed/removed/added)

Is it then also possible to find out what is the filesize change of this file?

like image 859
wa4557 Avatar asked May 06 '26 02:05

wa4557


2 Answers

One close approximation could be to use --numstat to output the amount of lines changes in each file and sort accordingly. This will produce a list of files sorted from the file with the most lines added to it in this commit to the one with the least:

$ git show <commit hash> --pretty=tformat: --numstat | sort -nr
like image 188
Mureinik Avatar answered May 08 '26 15:05

Mureinik


Is it then also possible to find out what is the filesize change of this file?

To get the file size use this:

git ls-tree -r -l <commit> <file path>
like image 44
CodeWizard Avatar answered May 08 '26 16:05

CodeWizard