Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use git commit history to find project hot-spots? [duplicate]

Tags:

git

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?

like image 434
benjismith Avatar asked Aug 28 '13 15:08

benjismith


People also ask

How do I get the history of a commit in Git?

After you have created several commits, or if you have cloned a repository with an existing commit history, you’ll probably want to look back to see what has happened. The most basic and powerful tool to do this is the git log command. These examples use a very simple project called “simplegit”. To get the project, run

How do I get the project’s git log?

The most basic and powerful tool to do this is the git log command. These examples use a very simple project called “simplegit”. To get the project, run: When you run git log in this project, you should get output that looks something like this:

How to view log size in git history?

Log Size in Git is an option in Git Log to tell you about the log-size in a digit. It outputs an additional line with log-size <number> as shown in the below image after typing the command: Note: I have shown you the last commit only. You will get a sequence of commits in reverse chronological order.

What is the difference between git log and commit?

Remember git log is as useful as git commit because you will regularly be seeing the history of your commits and that is the main focus of Git, that you can see the history of commits. I would like you to practice these commands in different ways and as much as you can. We will move on to our next tutorial.


1 Answers

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
like image 74
Sergey K. Avatar answered Oct 02 '22 20:10

Sergey K.