Ignore everything except one directory in .gitignore

后端 未结 1 468
广开言路
广开言路 2021-01-03 12:11

I have the following directory structure:

/app
/src
    /MyProject
        /FirstProject
            /Controller
                /file-1-1.php
                       


        
相关标签:
1条回答
  • 2021-01-03 13:16

    This .gitignore will actually work:

    /app
    /vendor
    /web
    /src/**/**
    !src/**/
    !/src/MyProject/SecondProject/Resources/**
    

    mipadi's answer refers to a mechanism introduced in git 2.7.0 and... reversed in 2.7.1!

    The only rule left is:

    It is not possible to re-include a file if a parent directory of that file is excluded.

    Hence the need for white-listing src sub-folders, before white-listing Resources content.

    I tested the above with:

    > git --version
    git version 2.7.1.windows.1
    
    0 讨论(0)
提交回复
热议问题