LoginSignup
3
4

More than 1 year has passed since last update.

git diff コメント行無視で変更行数を数える

Last updated at Posted at 2021-10-16

自分用メモ。論理LOCでステップ数を数えるため用。
(新規ファイルではなく既存ファイルの変更行数を数える)

変更した行数の確認

git diff --stat -w -B -I '^\s*\/' <変更前のコミットID> <変更後のコミットID>

変更した内容の確認

git diff -w -B -I '^\s*\/' <変更前のコミットID> <変更後のコミットID>

<変更前のコミットID> <変更後のコミットID>に関してはブランチ同士でも確認可能

--stat 変更行数を確認するときに役立つ
-w スペースのみの変更も無視する
-B 空行の追加・削除を無視する
-I 正規表現にマッチした表現を無視する

正規表現 '^\s*\/'
* 直前の文字が0回以上繰り返す場合にマッチ
\s 垂直タブ以外のすべての空白文字
^ 直後の文字が行の先頭にある場合にマッチ

以下のサイトを参考にさせていただきました。大変助かりました。


git diff関連 参考サイト

https://qiita.com/uedatakeshi/items/5e467b3aaa7a0ecfa011

https://maku77.github.io/git/stats/count-changes.html

https://iww.hateblo.jp/entry/20110605/p1

    
正規表現 参考サイト

https://murashun.jp/article/programming/regular-expression.html

3
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4