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

Re: gitignore excludes not working?

From
Duy Nguyen <pclouds@gmail.com>
Date
Dec 7, 2013, 03:20 UTC
Message-ID
<CACsJy8CyvSP9y7ui=2h7oFyeYCJK7WTdpqoSk00SM=LdpEokyQ@mail.gmail.com>
In-Reply-To
<CACPiFCJ0Jj1M8KCrwus=DeRSBE2O3HKhvEo-UJhHoZDhHTzsSA@mail.gmail.com>

On Sat, Dec 7, 2013 at 12:26 AM, Martin Langhoff <martin.langhoff@gmail.com> wrote:

Show 8 quoted lines
> # Untracked files:
> #   (use "git add <file>..." to include in what will be committed)
> #
> # modules/boring/
> # modules/interesting/other.c
>
> $ echo '/modules/' > .gitignore
> $ echo '!/modules/interesting/' >> .gitignore

Once you ignore the directory "modules", it won't bother with anything inside. As a result, !/modules/interesting/ is ignored. Turning the first rule to /modules/* like Jiang Xin showed does the trick because git is told to ignore entries inside 'modules', not 'modules' itself.

I think the best we could do is turning /modules/ into /modules/* internally. But it only works for simple cases like yours. If you write /mo*ules/, I don't think we can make git smart enough to correlate /mo*ules/ to !/modules/interesting/. So the second best thing is improve documents about this case, which is what kb/doc-exclude-directory-semantics does (currently on 'next').

-- 
Duy
Previous: Jiang Xin
Message 3 of 3 in “gitignore excludes not working?”
  1. Martin LanghoffDec 6, 2013
  2. Jiang XinDec 7, 2013
  3. Duy NguyenDec 7, 2013

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.