.gitignore exclude folder but include specific subfolder

后端 未结 17 1579
一个人的身影
一个人的身影 2020-11-21 06:36

I have the folder application/ which I add to the .gitignore. Inside the application/ folder is the folder application/language

17条回答
  •  有刺的猬
    2020-11-21 07:16

    I have found a similar case here, where in laravel by default, .gitignore ignores all using asterix, then overrides the public directory.

    *
    !public
    !.gitignore
    

    This is not sufficient if you run into the OP scenario.

    If you want to commit a specific subfolders of public, say for e.g. in your public/products directory you want to include files that are one subfolder deep e.g. to include public/products/a/b.jpg they wont be detected correctly, even if you add them specifically like this !/public/products, !public/products/*, etc..

    The solution is to make sure you add an entry for every path level like this to override them all.

    *
    !.gitignore
    !public/
    !public/*/
    !public/products/
    !public/products/*
    !public/products/*/
    !public/products/*/
    !public/products/*/*
    

提交回复
热议问题