From bfb1379951634c73183368f28eec5670d1ae3dc7 Mon Sep 17 00:00:00 2001 From: Changlang Kuang Date: Fri, 12 Aug 2016 19:04:12 +0800 Subject: [PATCH] add: Show how many lines does an author contribute (#121) --- README.md | 14 ++++++++++++++ tips.json | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index c3c31a8..fcf5404 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Show the author, time and last revision made to each line of a given file](#show-the-author-time-and-last-revision-made-to-each-line-of-a-given-file) * [Group commits by authors and title](#group-commits-by-authors-and-title) * [Forced push but still ensure you don't overwrite other's work](#forced-push-but-still-ensure-you-dont-overwrite-others-work) +* [Show how many lines does an author contribute](#show-how-many-lines-does-an-author-contribute) @@ -910,5 +911,18 @@ git shortlog git push --force-with-lease ``` +## Show how many lines does an author contribute +```sh +git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += ; subs += ; loc += - } END { printf "added lines: %s removed lines: %s total lines: %s +", add, subs, loc }' - +``` + + +__Alternatives:__ +```sh +git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += ; subs += ; loc += - } END { printf "added lines: %s, removed lines: %s, total lines: %s +", add, subs, loc }' - # on Mac OSX +``` + diff --git a/tips.json b/tips.json index 75dd558..85c762d 100644 --- a/tips.json +++ b/tips.json @@ -392,4 +392,8 @@ }, { "title": "Forced push but still ensure you don't overwrite other's work", "tip": "git push --force-with-lease " +},{ + "title": "Show how many lines does an author contribute", + "tip": "git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s removed lines: %s total lines: %s\n\", add, subs, loc }' -", + "alternatives": ["git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"added lines: %s, removed lines: %s, total lines: %s\n\", add, subs, loc }' - # on Mac OSX"] }]