Odd .gitignore behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Perhaps I'm misreading the manpage, but I think this is wrong:

    % mkdir base; cd base
    % git init
    % mkdir -p sub1/sub2
    % cd sub1
    % echo foo > .gitignore; echo '!sub2/foo' >> .gitignore
    % touch sub2/foo
    % git add sub2/foo
    The following paths are ignored by one of your .gitignore files:
    sub1/sub2/foo
    Use -f if you really want to add them.
    fatal: no files added

So sub1/sub2/foo matches the first pattern in sub1/.gitignore, but it
also matches the negated pattern '!sub2/foo' (in the same file, so
precedence isn't an issue).  And the manpage says

       o An optional prefix ! which negates the pattern; any matching
           file excluded by a previous pattern will become included
           again. If a negated pattern matches, this will override
           lower precedence patterns sources.

So surely sub1/sub2/foo ought to be included again?  Or is the first
line in sub1/.gitignore not "a previous pattern" in this sense?

If I move the "foo" pattern up a level, creating a .gitignore in base
just containing "foo", then sub1/sub2/foo is still regarded as
ignored, even though it surely matches the negating pattern
sub1/.gitignore, and that should be of higher precedence than the
pattern in base/.gitignore?
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux