I was searching for this answer here on SO but nothing was similiar or I got lost. I am trying to exclude all in specific subfolder except one folder. Probably I could do all paths manually, but I think there should be clever way. My file structure:
.gitignore
test/
file1
file2
sim_case/
file1
file2
include/
file1
file2
In .gitignore I have:
**/sim_case
And that is excluding everything from sim_case, but I would like to include folder "include". I tried some variations, and nothing worked.
!**/sim_case/include
!**/sim_case/include/
!**/sim_case/include/*
!sim_case/include/
!sim_case/include/
!sim_case/include/*
I did little research and it seems that the best option to exclude only files inside "sim_case" folder is to use:
**/sim_case/*
!**/sim_case/include
That allows to have more complex file structure
test/sim_case/include
test1/sim_case/include
etc.
The result from "git status":
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
new file: test/file1
new file: test/file2
new file: test/sim_case/include/file1
new file: test/sim_case/include/file2
new file: test1/file1
new file: test1/file2
new file: test1/sim_case/include/file1
new file: test1/sim_case/include/file2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With