Question: 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 the other (additions/deletions). The following Perl one-liner illustrates most of what I want:

```
git diff master.. | perl -lnwe 'print unless /^(new|deleted) file/../^diff/ and not /^diff/'

```

But that leaves `diff --git a/path b/path` lines for the files that were new or deleted. Plus it'd be much nicer if I didn't have to parse (also fails if any hunk contains anything matching /^diff/, for example).

Another alternative I tried was:

```
git diff --name-status (args) | perl -lnwe 'print if s/^M\s+//' | xargs git diff (args) --

```

Its output is better, but it still feels hackish.

Answer: 
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](https://github.com/git/git/commit/16726cfa0c3ad5d0d261bd7068014e659cb989da) (14 Jul 2016) by [Junio C Hamano (`gitster`)](https://github.com/gitster).  

(Merged by [Junio C Hamano -- `gitster` --](https://github.com/gitster) in [commit 2f8c654](https://github.com/git/git/commit/2f8c654edb0c8805749c60228ad9abb5984fba63), 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)](https://github.com/git/git/commit/7f2ea5f0f2fb056314092cce23202096ca70f076) **taught the "`--diff-filter`"
> mechanism to take lowercase letters as exclusion**, but we forgot to
> document it.
> 
> 
> 

So [the documentation on `diff-options`](https://github.com/git/git/blob/16726cfa0c3ad5d0d261bd7068014e659cb989da/Documentation/diff-options.txt#L402-L404) now (finally) includes:

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

Make sure to use **[Git 2.36 (Q2 2022)](https://stackoverflow.com/a/71190099/6309)**.
To see all modified and new files you can use

```
git diff --name-only --diff-filter=ACMR PREV_VERSION master

```

`PREV_VERSION` is the hash of your first commit.

To get an export as zip you can use this code

```
git archive --output=export.zip HEAD $(git diff --name-only --diff-filter=ACMR PREV_VERSION HEAD)

```

Note: `.gitignore` is not in `export.zip`