# git diff --git-ignore

2 messages from 2021-09-19 to 2021-09-20. Participants: Aaron Gray, Junio C Hamano.
Thread: https://gitlist.dev/t/56541

## Aaron Gray, 2021-09-19 23:50

Subject: git diff --git-ignore
Message-ID: <CANkmNDf5KVn7Afj9xtvMGC0Ua7G6O3EOjBRtAfBOKOnaYgqVXA@mail.gmail.com>
URL: https://gitlist.dev/e/CANkmNDf5KVn7Afj9xtvMGC0Ua7G6O3EOjBRtAfBOKOnaYgqVXA%40mail.gmail.com

```
Hi,

Is it possible to add a --git-ignore flag to git diff so I only see
the diffs for what I really want to be looking at, and not what I
don't ;)

Regards,

Aaron
-- 
Aaron Gray

Independent Open Source Software Engineer, Computer Language
Researcher, Information Theorist, and amateur computer scientist.

```

## Junio C Hamano, 2021-09-20 02:23

Subject: Re: git diff --git-ignore
Message-ID: <xmqq4kagdlxx.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq4kagdlxx.fsf%40gitster.g
In-Reply-To: <CANkmNDf5KVn7Afj9xtvMGC0Ua7G6O3EOjBRtAfBOKOnaYgqVXA@mail.gmail.com>

```
Aaron Gray <aaronngray.lists@gmail.com> writes:

> Is it possible to add a --git-ignore flag to git diff so I only see
> the diffs for what I really want to be looking at, and not what I
> don't ;)

How does your --git-ignore option exactly guess differences for
which paths to show and which paths to exclude?  How do you tell the
"git diff --git-ignore" command which paths are what you really want
to be looking at?

If it is by magic, good luck writing such a feature ;-)

If it is like "I only am interested in changes in src/ directory and
the top-level Makefile", then perhaps using pathspec is what you
want.  E.g.

    $ git diff -- src/ Makefile
    $ git diff --cached -- src/ Makefile
    $ git diff master topic -- src/ Makefile
    $ git diff master...topic -- src/ Makefile

Modern Git even allows you to include negative elements to the
pathspec, e.g.

    $ git diff src/ ':(exclude)*.h'

would tell us "show only changes in the src/ directory, but do not
bother with changes to the dot-h files".

HTH

```
