Filter git diff by type of change

后端 未结 5 1380
醉梦人生
醉梦人生 2020-11-28 01:36

Is there a way to limit git diff to changed files?

I\'d like to see the differences between two commits, but exclude paths that don\'t exist in one or t

5条回答
  •  醉梦人生
    2020-11-28 01:59

    As Git 2.10 (Q3 2016) will remind us, there is an easier way to "show everything except added/deleted files." (actually since Git 1.8.5, July 2013)

     git diff --diff-filter=ad master..
    

    See commit 16726cf (14 Jul 2016) by Junio C Hamano (gitster).
    (Merged by Junio C Hamano -- gitster -- in commit 2f8c654, 08 Aug 2016)

    diff: document diff-filter exclusion

    In v1.8.5 days, 7f2ea5f (diff: allow lowercase letter to specify what change class to exclude, 2013-07-17) taught the "--diff-filter" mechanism to take lowercase letters as exclusion, but we forgot to document it.

    So the documentation on diff-options now (finally) includes:

    These upper-case letters can be downcased to exclude.
    E.g. --diff-filter=ad excludes added and deleted paths.

提交回复
热议问题