I want to keep a few files in the repository but prevent updating them. Unfortunately looks till the file is at the repository even if it matches gitignore pattern can be updated. I want to commit (final) a version of that file(s) but prevent any update. Anyone can have his own version of that files but can't commit them and they should be ignored during commit. Is that possible?
CodePudding user response:
Anyone can have his own version of that files but can't commit them and they should be ignored during commit. Is that possible?
Not in Git itself.
You can probably get pretty close to what you want, with some combination of:
- A pre-commit hook can be used to make sure certain custom conditions are met. You could create a condition that the file is not in the list of changes for the commit. You then could ask your collaborators to please use that commit hook. Note they could choose not to if they wish.
- Do you use a Git SCM tool? Many tools offer policies you could associate to a branch. You could use a gated checkin or branch policy to prevent completing a Pull Request that modifies specific files.