excluding hooks solution
No. The Git server, which is a bare repository that sits somewhere and just interacts with it, does not care about which object it is pushing at. It simply copies objects into its own database of objects and changes some reference pointers from time to time. There is nothing in it that could look at tree objects and check if any path matches a path that you would like to exclude.
The only way to do this is to use interceptors, either a pre-reception, or an update hook. You will receive a new referent and see if the paths you want to exclude will be affected in the new commits. If they are, you can interrupt the press.
source share