GIT - how to ensure file exclusion by the server?

I want to force the git server to disconnect the file. Users should not delete a file that does not comply with the rules in the central repository. I tried to set the rules in / info / exclude on the server side of git, but ignore it.

Is there any way to do this? (excluding hook solutions).

thanks for the help

+4
source share
3 answers

You can ask users to add a system config:

git config --system core.excludesfile /share/path/to/system/wide/gitignore 

Thus, users are referenced in a common (gitignore) file.

+1
source

You can create a pre-receive hook that parses push and looks for file extensions.

I do this to avoid clicking on files, but files with specific extensions are allowed (jpg, mov, mp3, etc.)

+1
source

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.

0
source

Source: https://habr.com/ru/post/1490872/


All Articles