Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting the Total Lines of Changes in a GitHub pull request(i.e. between two branches)

Is there a way to count the total number of change that appears in a pull request ? I wanted to build a tool that should restrict the users to commit, if the PR Lines of Change is more than a certian threshold.

I tried doing git diff origin/master..<featureBranch> but it's giving some incorrect lines of change. Any help is appreciated.

like image 505
Ayan Avatar asked Sep 14 '25 08:09

Ayan


1 Answers

For counting changed lines of code in pull request you should use

git log --shortstat sha_of_commit

or

git log --stat sha_of_commit (more verbose output)

or if you have some diff, not commit, then you should swap diff with log:

git diff --stat / --shortstat
like image 194
Robert Pawlak Avatar answered Sep 15 '25 23:09

Robert Pawlak