Help us understand the problem. What is going on with this article?

Git CLIでマージ数、コミット数などの統計情報を取る

特定期間内の master ブランチへのマージ数

例えば、過去1週間分の集計をしたい場合

master ブランチをcheckoutしたwork directoryで以下を実行

git log --after="`date -d '-1 week' '+%Y-%m-%d 00:00:00'`" --before="`date -d today '+%Y-%m-%d 00:00:00'`" --oneline --merges | grep "into 'master'" | wc -l

特定期間内のcommit数

git log --after="`date -d '-1 week' '+%Y-%m-%d 00:00:00'`" --before="`date -d today '+%Y-%m-%d 00:00:00'`" --oneline --no-merges | wc -l

特定期間内にcommitされたファイル数

git log --after="`date -d '-1 week' '+%Y-%m-%d 00:00:00'`" --before="`date -d today '+%Y-%m-%d 00:00:00'`" --numstat --no-merges --pretty=format:"" | sed '/^$/d' | wc -l

特定期間内にcommitされたファイルの additions と deletions それぞれの合計

git log --after="`date -d '-1 week' '+%Y-%m-%d 00:00:00'`" --before="`date -d today '+%Y-%m-%d 00:00:00'`" --numstat --no-merges --pretty=format:"" | sed '/^$/d' | awk '{plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'

出力例

+29663, -32369

最後の awk処理は以下を参考にした。
http://koyamay.hatenablog.com/entry/2014/10/06/022654

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away