Behavioral Code Analysis with Git

This section summarizes the most important Git commands. Please note that the trailing backslash, \, is used to break the lines so that they appear readable in the text, and you want to omit those backslashes and join the lines together when you enter the commands.

Detect Hotspots

Here we ask Git to deliver a list of all modified files in every commit. We then remove empty lines—a side effect of the Git command—with the egrep command. The command then counts the frequency of the resulting file names and delivers the results sorted in descending order:

 adam$ ​​git​​ ​​log​​ ​​--format=format:​​ ​​--name-only​​ ​​|​​ ​​egrep​​ ​​-v​​ ​​'^$'​​ ​​|​​ ​​sort​​ ​​\
  ​​|​​ ​​uniq​​ ​​-c​​ ​​|​​ ​​sort​​ ​​

Get Software Design X-Rays now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.