Skip to content

Instantly share code, notes, and snippets.

@KarlHeitmann
Created May 20, 2024 15:18
Show Gist options
  • Save KarlHeitmann/f00ec8de97446c7437132bb8a2287371 to your computer and use it in GitHub Desktop.
Save KarlHeitmann/f00ec8de97446c7437132bb8a2287371 to your computer and use it in GitHub Desktop.
Command to get hot files in git repository

Source: https://dev.to/augustohp/files-with-the-most-changes-on-git-repository-46l1

Command to get all files with counts on git log

git log --name-only --pretty="format:" | sed '/^\s*$/'d | sort | uniq -c | sort -nr
# get head files:
git log --name-only --pretty="format:" | sed '/^\s*$/'d | sort | uniq -c | sort -nr | head
# filter files, eg: by "controller" pattern
git log --name-only --pretty="format:" | sed '/^\s*$/'d | grep controller | sort | uniq -c | sort -nr | head

You can combine with this command to know more details about the changed files:

git log --stat -- $(!!)
git log --name-only --pretty="format:" | sed '/^\s*$/'d | sort | uniq -c | sort -nr | head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment