git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff --git-ignore

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 20, 2021, 02:23 UTC
Message-ID
<xmqq4kagdlxx.fsf@gitster.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
Previous: Aaron Gray
Message 2 of 2 in “git diff --git-ignore”
  1. Aaron GraySep 19, 2021
  2. Junio C HamanoSep 20, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.