threads / discuss / 56541

git diff --git-ignore

Subject: git diff --git-ignore

## tl;dr

2 messages between Sep 19, 2021 and Sep 20, 2021.

replies: 1people: 2as markdown or json

Aaron Gray· Sep 19, 2021, 23:50 UTC · lore
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· Sep 20, 2021, 02:23 UTC · re: Aaron Gray · lore

Re: git diff --git-ignore

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

← back to recent threads