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: To get the number of commits for each user execute git shortlog -sn --all. To get the number of lines added and delete by a specific user install q and then execute: git log --author="authorsname" --format=tformat: --numstat | q -t "select sum(c1), sum(c2) from -"
The git log command displays committed snapshots. It lets you list the project history, filter it, and search for specific changes.
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With