gitignore - only allow certain extensions and files

后端 未结 2 1661
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 16:14

not sure why this isn\'t working, as I\'ve done this loads! Maybe I\'m having a bad day...

I\'m using the following code to ignore all files except for certain filen

相关标签:
2条回答
  • 2020-12-14 16:45

    The solution is to tell Git not to ignore sub directories:

    *
    !.gitattributes
    !.gitignore
    !readme.md
    !.gitkeep
    !*.php
    !*/
    

    Otherwise, only the *.php files in the first directory level will be accepted and all sub directories will be ignored.

    0 讨论(0)
  • 2020-12-14 16:54

    The most sophisticated method to achieve this

    create .gitignore file in repository root, and add below lines to .gitignore file

    *.*
    !.gitattributes
    !.gitignore
    !readme.md
    !.gitkeep
    !*.php
    

    this will include all specified file from directory and subdirectory recursively.

    tested on

    git version 2.12.2.windows.2

    0 讨论(0)
提交回复
热议问题