Reputation: 12717
I'm collaborating with a colleague through Git. There are some files which he normally shouldn't modify, but it can happen by accident. Moreover, he is not experienced with Git.
What is the best way to make a setting in his Git such that
Upvotes: 0
Views: 1148
Reputation: 3549
Do you have control over the server? A pre-receive
hook that checks the pusher and the files pushed and blocks any pushes that violate the policy would do what you want.
If these files are all related, I'm not a fan of making multiple small repos.
As for ensuring that the user's local changes to these files are overwritten on pull... Philosophical differences about allowing somebody you trust so little to touch your code aside... They would need to either do their git pull
via a wrapper script that does something like a git checkout -- <restricted paths>
afterwards, or alternately have a similar post-pull
hook. Both would still require compliance to either run the wrapper or install the hook.
Upvotes: 1
Reputation: 249592
You should create a separate repo for the files that require separate permissions. Then it's easy to deny push access to that repo for people who should not modify those files. You can make one of the repos a submodule of the other, to keep them "in sync."
Upvotes: 1