如何在git中保留文件权限? [英] How to preserve the file permission in git?
问题描述
我遇到一个问题,我花了很长时间找到一个解决方案,仍然无法得到一个。
I encountered a problem which took me a long time to find a solution and still fail to get one.
我遇到的问题是DatabaseError:尝试写一个只读数据库',当我试图通过git部署我的网站到Django托管。
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.
似乎git将更改文件的权限,从777到755 。
但是每当我提交我的项目,这个更改将持续。但是,我仍然需要写入我的数据库(sqlite数据库)。
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).
有没有人有一个建议配置我的git保持每次提交的权限模式? / p>
Does anyone have a suggestion to configure my git to preserve the permission mode at each commit?
推荐答案
总之,你不能。
有像etckeeper这样的项目可以自动做,或者你可以写一个小钩子脚本,这将修正权限(这可能是我会做的)。
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:
#!/bin/sh
chmod -R XXX file_or_directory/
例如 scripts / fix_permissions /
,然后将其作为 post-reception 钩子运行,将其链接到 .git / hooks / post-receive
。
To, eg, scripts/fix_permissions/
, then run it as a post-receive hook by simlinking it into .git/hooks/post-receive
on the server.
这篇关于如何在git中保留文件权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!