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