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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.