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

Re: How to exclude files from "git diff"

From
Jeff King <peff@peff.net>
Date
Jan 5, 2010, 06:45 UTC
Message-ID
<20100105064509.GC19025@coredump.intra.peff.net>
In-Reply-To
<6dc9ffc80912180909q2e9cbe30r7c802a2152c5954@mail.gmail.com>
On Fri, Dec 18, 2009 at 09:09:15AM -0800, H.J. Lu wrote:
> I have some bookkeeping files in my git repository.  How do I
> exclude them from "git diff"? Does "git diff" support
> 
> # git diff --exclude="foo.*.bar*"

No, I don't believe there is a way to do that. You would have to do something like:

  git diff $(git ls-files | grep -v whatever)

The usual concept of "exclusion" for git is not to track files at all via the .gitignore mechanism. Are these files that have content you really _want_ in the repository, but you just don't want to see them when doing some diffs? Or are they files that could not be in the repository at all?

-Peff
Previous: H.J. LuNext: H.J. Lu
Message 2 of 7 in “How to exclude files from "git diff"”
  1. H.J. LuDec 18, 2009
  2. Jeff KingJan 5, 2010
  3. H.J. LuJan 5, 2010
  4. Dmitry PotapovJan 5, 2010
  5. H.J. LuJan 5, 2010
  6. Nguyen Thai Ngoc DuyJan 5, 2010
  7. Junio C HamanoJan 5, 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.