It is easy to count the lines of code between two branches and know the net delta. Is there a way to measure the added/edited lines of code in a git merge, ignoring the removed lines?
CodePudding user response:
The simplest way is to use git diff
and grep for that
marker at the beginning of added lines, but removing
since it's for file paths.
git diff <sha-before-merge> <sha-after-merge> |
grep -v '^ ' |
grep '^ ' |
wc -l
Although using --numstat
might be even easier:
git diff --numstat <sha-before-merge> <sha-after-merge> |
awk '{ s = $1 } END { print s }'
the git diff
command gives you the number of added lines in each file in the first column, and the awk
one-liner tallies it.