While working on the Git repository with many team members, it becomes handy for developers to view when and how the Git repository is modified by other developers in terms of contribution, collaboration, and size. Moreover, multiple logs with full details are provided, and it also provides several commands to generate the particular Git repository statistics.
In this post, you will learn:
- How to Generate Statistics of Git Repository Including Username and Number of Logs?
- How to Generate the Statistics Excluding the Merges?
- How to Generate and Filter Statistics With a Given Date?
- How to Generate Statistics Along With User Email Addresses?
- How to Generate Statistics of Git Repository Along Number of Inserted and Deleted Files?
How to Generate Statistics of Git Repository Including Username and Number of Logs?
If you need to generate the statistics of the Git repository, including the username and number of logs, then check out the instructions below.
First, use the “cd” command to navigate to the desired Git directory:
To generate a statistic of the Git repository, including the number of logs and username, run the following command:
Here, the “-s” option is used to display the statistics, and the “-n” option is used to generate the number logs:
How to Generate the Statistics Excluding the Merges?
To generate the statistics excluding the merger, execute the “git shortlog” command along with the “-sn” option to display the number of logs along with the username, and the “–no-merge” parameter is used to exclude the performed merges:
How to Generate and Filter Statistics With a Given Date?
Suppose developers want to generate the statistics of a specific date. In that case, they can utilize the “git shortlog” command with “-s” and “-n” options to show the number of logs and the “–since” parameter to get the provided date statistics.
For instance, we have provided the “OCT 28 2022” date:
How to Generate Statistics Along With Users’ Email Addresses?
To get the Git repository statistics along with the user email addresses, execute the “git shortlog” command with the “-sne” option:
Here, the “e” flag is used for getting the user email address:
How to Generate Statistics of Git Repository Along Number of Inserted and Deleted Files?
To generate the logs of a particular Git repository with the number of inserted and deleted files, run the “git log” command with the “–format” option with the “author: %ae” value that will show a single commit, and the “–numstat” option will provide the number of insertions:
That’s all! We have compiled the different scenarios of generating the statistics from the Git repository.
Conclusion
There are several scenarios to generate the statistics from the Git repositories. To do so, first, move to the particular Git repository and execute the multiple commands, such as the “$ git log –format=author: %ae” –numstat” command for generating the statistics, including the number of inserted, deleted files and any more commands. This post provided several commands to generate the statistics from the Git repository.