7

I am working on a real mess of a project and we've been planning to refactor it for months but nobody has the time. I want to see which files are most modified because the features/codes contained in those files will have the priority on refactoring and increasing my productivity.

Is it possible to get number of times each file was modified since first commit or a specific week, in a table format or something, in git? If so, how?

2
  • 8
    This is usually called a "churn metric", see this command for an example. Commented May 10, 2017 at 10:46
  • After 6+ years, I thank you nonetheless, Lord Lasse V. Commented Jun 29, 2023 at 20:51

1 Answer 1

5

To count the number of commits for each of your files, you could do something like this

#!/bin/bash for file in *.php; do echo $file git log --oneline -- $file | wc -l done 

"git log" is the key git command here.

Here are some git commands and options to look at

git log git log --oneline 

To get a log of changes for a specific file

git log -- filename 

To get a log of changes for a specific file during a specific date you can do

git log --after="2017-05-09T16:36:00-07:00" --before="2017-05-10T08:00:00-07:00" -- myfile 

You may want to try

git log --pretty=format 

you can look up all the different formats

You could get a private repository on github and push it all up there; that would be a nice graphical way to see all the changes for any of your changed files.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.