11

I'm joining a new project with a long and storied commit history, and I'd like to use that history to show me the hot-spots in the project: the files that have been most commonly (and most recently) edited.

Ideally, I'd like to avoid writing more than a few lines of script (ruby, python, javascript; doesn't matter which).

Anybody know of a one-liner that can rank git project files according to their activity in a commit history?

benjismith
  • 16,559
  • 9
  • 57
  • 80

1 Answers1

17

You can use this one-liner to print the top 100 most frequently changed files:

git log --pretty=format: --name-only | sed '/^\s*$/d' | sort | uniq -c | sort -rg | head -100
dogmatic69
  • 7,574
  • 4
  • 31
  • 49
Sergey K.
  • 24,894
  • 13
  • 106
  • 174
  • 1
    I would suggest adding a `sed '/^\s*$/d'` pipe between the git and the sort command, so we don't count newlines as "changed files". – imolit Dec 01 '16 at 17:33
  • 1
    The sort pipe did not work on windows had to change to this `git log --pretty=format: --name-only | sort | uniq -c | sort /R | head -100` – Stian Standahl Jun 05 '19 at 06:34