Reputation: 125
I have question regarding ignore and exclude rules in .gitignore.
So I have a very large file tree where I want to ignore all lib files except a specific lib file which is a text file with a .lib extension:
What I have in my .gitignore file:
# exclude rule
!text.lib
# ignore rule
*.lib
However, I can not see all the text.lib files in my file tree when issuing a git status. The '!text.lib' is overrulled by *.lib'
How to make a rule that can solve this?
Thank you very much:-)
Upvotes: 1
Views: 400
Reputation: 20158
If you want to reinclude a pattern which was ignored before you have to specify it after the pattern which ignores it.
From the gitignore documentation:
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again.
So your ignore file has to look like this:
*.lib
!text.lib
Hope that helps!
Upvotes: 1
Reputation: 1270
Please check the answer for this stackoverflow question. .gitignore exclude folder but include specific subfolder
You will just need to change expressions.
Upvotes: 0