Reputation: 1056
I'm having some troubles with a git repository that have some files in readonly mode (chmod 0440).
Sometime, one of those files get modified on another branch ; and when you try to checkout that branch, git fails to update that file with a
warning: unable to unlink path/to/the/file: Permission denied
The problem is that those files need to be in readonly mode, because the framework used beyond those files throws heavy warning messages when those files are writable, and even more problematic, each time we are (re)installing the framework in our continuous integration process, the framework updates those files to be in readonly mode.
I tried to use git hooks to automatically chmod those files to 0664 before checking out any file/branch, then chmod them back to 0440, but I'm not sure such hooks exist.
An unwanted solution would be to chmod myself those files to 0664 each time I know they could change with git, then chmod them back to 0440 to avoid pushing writable files in a prod environment, but it would lead to fails for sure.
Another solution would be to commit them in 0664 mode and update our continuous integration process to re-chmod those file to 0664 after the framework is being (re)installed and totally ignore the warnings ; while keeping the chmod to 0440 for the prod environment.
What you guys do you think of this problem, and what is the best solution I could have to fix it ?
Upvotes: 2
Views: 1502
Reputation: 38619
Sounds like you are trying to use Git as a deployment tool.
Git is not meant as deployment tool. One of the most important reasons is, that it doesn't track permissions except for the user-executable one. If a file is read-only, Git of course cannot modify it, because it is read-only.
Maybe you should read http://gitolite.com/deploy.html to get some hints on how to maybe be able to build a deployment tool around Git.
Upvotes: 2