I just created a folder like this:
.
├── config
│ ├── subfolder
│ │ └── config.xml
│ └── subfolder2
│ └── config.xml
├── .gitignore
├── log2.txt
└── log.txt
And I've typed git init
in this folder. I want to ignore everything except .gitignore
, and all config.xml
files.
These are the .gitignore
I have tried:
1:
*
!.gitignore
!**/config.xml
2:
*
!.gitignore
!config/*/config.xml
3:
*
!.gitignore
!**/config.xml
git status
shows .gitignore
is the only untracked file with any one of the gitignore settings above.
I want all the config.xml
files to be on the untracked files list too.
I've read the tutorial at atlassian. And I think that maybe it's the following rule that makes me not able to ignore everything except certain files under subdirectories.
I'm using git version 2.11.0.windows.1
in windows 10 operating system. Anyone knows why my .gitignore
file is not working the way I expect?
Thanks to torek's link, I finally come up with the following solution:
/**
!/**/
!.gitignore
!**/config.xml