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

Re: git diff/grep add --exclude option

From
Johannes Gilger <heipei@hackvalue.de>
Date
Apr 15, 2010, 20:25 UTC
Message-ID
<slrnhsetj6.esr.heipei@dualtron.heipei.net>
In-Reply-To
<1271106125.3031.31.camel@kheops>
On 2010-04-12, Sylvain Rabot <sylvain@abstraction.fr> wrote:
> I was surprised to not find an option to exclude file from git diff/grep
> outputs like -x for diff or --exclude for grep. It's too bad because it
> can be really useful.

Yeah, me too, but probably because I never needed it ;) Anyway, there were some discussions on this before [1]. I thin a viable workaround is using ls-files and grep. Quick example:

git diff -- $(git ls-files | grep -Ev "(^Documentation|^compat/mingw.c)")

would show everything except the whole Documentation subtree and mingw.c from compat. Now, you might even whip that into your very own shellscript or use a git alias (dirty):

[alias]
  ediff = "!sh -c 'git diff -- $(git ls-files | grep -Ev $0)'"
And call it with 
  git ediff "(Documentation|compat/mingw.c)"

Greetings, Jojo

[1] - http://lists-archives.org/git/708604-how-to-exclude-files-from-git-diff.html
-- 
Johannes Gilger <heipei@hackvalue.de>
http://heipei.net
GPG-Key: 0xD47A7FFC
GPG-Fingerprint: 5441 D425 6D4A BD33 B580  618C 3CDC C4D0 D47A 7FFC
Previous: Sylvain Rabot
Message 2 of 2 in “git diff/grep add --exclude option”
  1. Sylvain RabotApr 12, 2010
  2. Johannes GilgerApr 15, 2010

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.