Reputation: 340
I have this structure:
versions
├── library-3.1
│ ├── Dockerfile
│ ├── options
│ └── armhf
│ ├── Dockerfile
│ └── rootfs.tar.xz
├── library-3.6
│ ├── Dockerfile
│ ├── options
│ └── x86_64
│ ├── Dockerfile
│ └── rootfs.tar.xz
...
I want git to ignore any folder under versions/**/
(like versions/**/armhf
and versions/**/x86_64
), but keep tracking the files options
and Dockerfile
Any ideas? Thanks!
Upvotes: 1
Views: 1092
Reputation: 1329802
Remember:
It is not possible to re-include a file if a parent directory of that file is excluded.
Ignore files:
versions/**
But not folders:
!versions/**/
Then you can exclude some files (because their parent folder are not ignored)
!versions/**/Dockerfile
!versions/**/option
Remember:
Upvotes: 0
Reputation: 66
# Ignore everything under 'versions/'...
versions/*
# ...except 'options' and 'Dockerfile'
!versions/**/options
!versions/**/Dockerfile
Add any additional files you need to the excluded list.
Alternatively, add a .gitignore file to each subdirectory that you want to ignore files in. This may provide better flexibility as the project grows.
Upvotes: 1