'Git: How to measure the amount of code changed in a period of time? [duplicate]
I'm looking for a command to execute against my git repo to discover the amount of code changed in a certain period of time.
I want to know how much code was changed since day 'X'. I don't really care about the percentage of code changed by each author.
Solution 1:[1]
Following up the excellent answer Gabriele found, the exact command you need is:
git log --since=31/12/2012 --numstat --pretty="%H" | awk '
NF==3 {plus+=$1; minus+=$2;}
END {printf("+%d, -%d\n", plus, minus)}'
(yes, you can paste that onto a single line, but the answer's more readable like this)
The key difference is the in a certain period of time requirement, handled by the --since
argument.
Solution 2:[2]
You can use the --stat
option of git diff
.
For instance
git diff --stat HEAD HEAD~1
will tell you what changed from the last commit, but I think what's closest to your request is the command
git diff --shortstat HEAD HEAD~1
which will output something like
524 files changed, 1230 insertions(+), 92280 deletions(-)
EDIT
Actually I found this great answer that addresses the same issue much better that I can do.
Solution 3:[3]
As a less awksome alternative:
REV=$(git rev-list -n1 --before="1 month ago" master)
git diff --shortstat $REV..master
The "before" date can of course be a more standard representation of time as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Community |
Solution 3 | Jussi Kukkonen |