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

Re: How to find out which gitignore blocks my git-add

From
Jeff King <peff@peff.net>
Date
Feb 6, 2009, 19:33 UTC
Message-ID
<20090206193359.GF19494@coredump.intra.peff.net>
In-Reply-To
<498C0525.5040100@gonsolo.de>
On Fri, Feb 06, 2009 at 10:38:45AM +0100, Gonzo wrote:
Show 7 quoted lines
> After doing a "git add file" I get the message:
>
> "The following paths are ignored by one of your .gitignore files:
> ..."
>
> Is there an easy way to find out which line in which gitignore file  
> blocks this add?
No, I don't think so.
> Would this be a viable addition to "git add -v"?

I think it might be useful to be able to get this information. However, rather than coupling it with "git add", it might make more sense to have a separate way to query "is this being ignored, and if so, by what pattern". Then you could use that tool to generally debug your .gitignore patterns.

I'm not sure how painful it would be to implement. You'd probably have to record and pass back that information from dir.c:excluded, which is where we decide whether or not a file is ignored (most of the code calls it "excluded", but it is the same concept). Want to take a stab at writing a patch?

-Peff
Previous: GonzoNext: Sitaram Chamarty
Message 2 of 17 in “How to find out which gitignore blocks my git-add”
  1. GonzoFeb 6, 2009
  2. Jeff KingFeb 6, 2009
  3. Sitaram ChamartyFeb 7, 2009
  4. Jeff KingFeb 7, 2009
  5. 1/2 refactor exclude handlingJeff King, Feb 7, 2009
  6. 2/2 give exclude mechanism a debug optionJeff King, Feb 7, 2009
  7. Junio C HamanoFeb 7, 2009
  8. Junio C HamanoFeb 7, 2009
  9. Jeff KingFeb 7, 2009
  10. Jeff KingFeb 7, 2009
  11. Junio C HamanoFeb 7, 2009
  12. Jeff KingFeb 8, 2009
  13. Junio C HamanoFeb 8, 2009
  14. Jeff KingFeb 8, 2009
  15. Sitaram ChamartyFeb 7, 2009
  16. Jeff KingFeb 7, 2009
  17. bisaniFeb 6, 2009

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.