LoginSignup
9
9

More than 5 years have passed since last update.

Gitで編集だけのログを表示したい

Last updated at Posted at 2013-12-05

たとえば、すごいでっかいコミットがあったとして、
ファイル追加とかファイル削除とかを無視して、編集した部分だけを見たい、なんていうことがある。

そんなときは、git log--diff-filterを使うとよい。

[rack#master] $ git whatchanged --diff-filter=M
commit 58c24bbafdd476d16d9c3778b2455625bb27f67e
Author: Martin Schürrer <martin@schuerrer.org>
Date:   Sun Jul 14 20:14:03 2013 +0200

    Fix bug in sendfile.rb

    The error message called `variation` without the env leading to an `ArgumentError`. It should call `type` instead.

:100644 100644 c247a3b... 8a67490... M  lib/rack/sendfile.rb

commit 977351595d7ff7d17cc4c4b2526922ef37b7c65e
Author: James Tucker <jftucker@gmail.com>
Date:   Thu Jul 4 16:17:43 2013 -0700

    Refactor rack static header rules application

:100644 100644 6b0762a... 41aec7f... M  lib/rack/static.rb

commit 65d3894224149ed3aee80293892bb368377913a1
Author: Garry Shutler <garry@robustsoftware.co.uk>
Date:   Wed Jul 3 19:43:50 2013 +0100

    Set HttpOnly for cookies using :http_only

:100644 100644 0c7091e... 43bbef3... M  lib/rack/utils.rb
:100644 100644 0ba17b1... 12b8b7b... M  test/spec_response.rb

commit cf13f31a74c46eb79032428d5efd176c4c35187c
Author: Prem Sichanugrist <s@sikac.hu>
Date:   Fri Jun 28 15:48:03 2013 -0400

    Add Response#unauthorized? helper

    This helper should come in handy when you want to test the authorization
    in your application.

:100644 100644 2beba7a... 2076aff... M  lib/rack/response.rb
:100644 100644 7ba1e0e... 0ba17b1... M  test/spec_response.rb

ちなみに、MModifiedMである。他にもAddedAや、DeletedDなどがある。

…ところでこの機能、だれが使うんだろう。

追記(2013.12.06 16:31)

MModifiedなファイルのみのdiffを表示してくれる。
だけど、Modifiedなファイル 以外のファイルのdiff を表示したい時はどうしたらいいんだろう。

と思ってたら、どうやらmと書けばよかったらしい。つまり、

$ git log --stat --diff-filter=m

である。
Mの逆だからmか。なるほど。

9
9
0

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
9
9