The documentation says
The first pattern that matches will decide the fate of a given file
So, they are matched top to bottom. It also says
A pattern beginning with a ! prefix negates the pattern: matching files are included (that is, not ignored). This can be used to override more general patterns that follow.
Given that, did you try this?
!/docs
!/.config
*