如何保留git中的文件权限?
我遇到了一个问题,我花了很长时间才找到解决方案,但仍然没有得到解决。
当我尝试通过 git 将网站部署到 Django 托管时,我遇到的问题是“数据库错误:‘尝试写入只读数据库’”。
看来 git 会改变我的文件的权限,从 777 到 755。 但每当我提交项目时,这种变化都会持续存在。但是,我仍然需要向我的数据库(sqlite 数据库)写入一些内容。
有人建议配置我的 git 以在每次提交时保留权限模式吗?
I encountered a problem which took me a long time to find a solution and still fail to get one.
The problem I had is 'DatabaseError: 'attempt to write a readonly database' when I tried to deploy my website through git to a Django hosting.
It seems like git will change the permission of my files, from 777 to 755.
But whenever I commit my project, this change will persist. However, I still need to write something into my database (sqlite database).
Does anyone have a suggestion to configure my git to preserve the permission mode at each commit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之,你不能。
更长的时间里,有像 etckeeper 这样的项目可以自动执行此操作,或者您可以编写一个小钩子脚本来修复权限(这可能就是我的做法)。
例如,如果您提交以下内容:
例如,
scripts/fix_permissions/
,则将其作为 post-receive 钩子,通过将其模拟链接到服务器上的.git/hooks/post-receive
中。In short, you can't.
In longer, there are projects like etckeeper which can do it automatically, or you can write a small hook script which will fix up the permissions (which is probably how I'd do it).
For example, if you commit something this:
To, eg,
scripts/fix_permissions/
, then run it as a post-receive hook by simlinking it into.git/hooks/post-receive
on the server.