Reputation: 41
I want to enforce file exclusion by the git server. Users should not be able to push file that doesn't match to rules to the central repository. I tried to setup rules in /info/exclude on the git server side, but it ignore it.
Is there a way to do that ? (excluding hooks solution).
Thanks for your help
Upvotes: 4
Views: 1110
Reputation: 2235
You can create a pre-receive hook that analyzes the push and looks for file extensions.
I do that to avoid binaries being pushed, but files with certain extensions are allowed (jpg, mov, mp3, etc)
Upvotes: 1
Reputation: 387745
excluding hooks solution
No. A Git server, that is a bare repository that sits somewhere and is just interacted with, does not care about what kind of object it gets pushed to. It just copies objects into its own object database and changes some ref pointers from time to time. There is nothing in it that would look at the tree objects and check if some path matches some path you would like to exclude.
The only way to do this would be using hooks, either the pre-receive or the update hook. You would get the new ref and see if the paths you want to exclude are touched within the new commits. If they are, you can abort the push.
Upvotes: 0
Reputation: 1324757
You could ask users to add a system config:
git config --system core.excludesfile /share/path/to/system/wide/gitignore
That way, users are referencing a shared (gitignore) file.
Upvotes: 1