忽略除某些子目录及其内容之外的所有内容

时间:2017-06-15 08:36:44

标签: git gitignore

所以我看过一些与我相似的帖子,但他们的答案似乎都不适合我。

我的文件夹结构类似于以下内容:

|-- identity
|   |-- custom
|   |   |-- pages
|   |   `-- static
|   |-- lib
|   |   `-- ext
|   |-- logs
|   `-- webapps
|-- oxauth
|   |-- custom
|   |   |-- pages
|   |   `-- static
|   |       `-- img
|   |-- lib
|   |   `-- ext
|   |-- logs
|   `-- webapps
`-- oxauth-rp
    |-- logs
    `-- webapps

我想忽略除custom文件夹及其内容之外的所有内容。

我尝试过以下忽略文件:

*
!.gitignore
!/custom/

*
!.gitignore
!/identity/custom/
!/oxauth/custom/

但除了我的root .gitignore文件外,它忽略了所有内容。

至少这就是我运行git status时所说的内容。并且custom / pages文件夹下有文件。 那么,我错过了什么?

1 个答案:

答案 0 :(得分:2)

根据我的测试,以下内容应达到预期的效果。

*
!*/
!.gitignore
!/oxauth/custom/**
!/identity/custom/**
相关问题