apache Subversion 如何处理文件权限和 .htaccess 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1215689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does Subversion handle file permissions and a .htaccess file?
提问by James Skidmore
I'm using Subversion for one of my PHP projects. I have two questions/issues:
我正在为我的一个 PHP 项目使用 Subversion。我有两个问题/问题:
- How are file permissions handled with Subversion? If I have a file that I CHMOD to 755, and I check that file into the repository, will it have the same permissions when it's checked out into other working copies? If it does not copy, do I really need to change the permissions with every checkout?
- I have a .htaccess file that I don't want to check into the repository. If I do an update on a working copy that contains a .htaccess (but the repository doesn't have that file), will the file be deleted or will the update leave it alone?
- Subversion 如何处理文件权限?如果我有一个 CHMOD 为 755 的文件,并且我将该文件检入存储库,那么当它检出到其他工作副本时,它是否具有相同的权限?如果它不复制,我真的需要在每次结帐时更改权限吗?
- 我有一个 .htaccess 文件,我不想签入存储库。如果我对包含 .htaccess 的工作副本进行更新(但存储库没有该文件),该文件会被删除还是更新会保留它?
回答by sunny256
- The only permission Subversion knows about, is the executable bit, which is stored as a special "svn:executable" property. If this property is defined, the file is checked out with the exec bit set. For the rw flags, it depends on your umask. If your umask is for example 0022, a file without the svn:executable bit will be checked out with permission 0644. If your umask is 0002, the permission will be 0664. If svn:executable is set, the exec bit is set for the owner, group and everyone else.
- If you don't mark the .htaccess for addition (svn add), svn will leave the file alone. It will not go into the repo when committing, and it will not be deleted when you run svn update. You will see a "?" in front of it when you run "svn status".
- Subversion 知道的唯一权限是可执行位,它存储为特殊的“svn:executable”属性。如果定义了此属性,则在设置了 exec 位的情况下检出文件。对于 rw 标志,这取决于您的 umask。例如,如果你的 umask 是 0022,一个没有 svn:executable 位的文件将被检出权限为 0644。如果你的 umask 是 0002,则权限将是 0664。如果设置了 svn:executable,则 exec 位被设置为所有者、组和其他所有人。
- 如果您没有将 .htaccess 标记为添加 (svn add),svn 将不理会该文件。提交时不会进入repo,运行svn update时也不会删除。你会看到一个“?” 当你运行“svn status”时在它前面。
回答by Bostone
For #2 you can simply add .htaccess to svn:ignore property. Here's a good take on what that does and how that work http://blog.bogojoker.com/2008/07/command-line-svnignore-a-file/Permission-wise if you check out file it gets read/write permissions unless it's executable which should have svn:executable permissions and will be checked out as such. The file can also be explicitly marked with svn:needs-lock which then makes it read-only when you checkout
对于#2,您可以简单地将 .htaccess 添加到 svn:ignore 属性。这是 对它的作用和工作方式的一个很好的理解http://blog.bogojoker.com/2008/07/command-line-svnignore-a-file/权限明智,如果您签出文件,它会获得读/写权限除非它是可执行文件,它应该具有 svn:executable 权限并且将被检出。该文件也可以用 svn:needs-lock 显式标记,然后在您结帐时将其设为只读
回答by Peter Parker
As already mentioned, SVN will not store permissions.
The reason is trivial:
The user who did the checkout will be owner of all files inside his working copy, so it does not make sense to give permissions as he already has read/write permissions on all files inside his working copy (depending on his umask).
For executable flag set svn-property svn:executable.
.htaccess file
You should add the .htaccess to the parent directories svn:ignore property.
However, SVN will never change or overwrite your changes without asking you first. So if some of your buddys will store the .accessfile into repository, SVN will stop update and will mention that your own .htaccess file must be removed to continue.
如前所述,SVN 不会存储权限。
原因很简单:
进行签出的用户将是其工作副本中所有文件的所有者,因此授予权限是没有意义的,因为他已经对其工作副本中的所有文件具有读/写权限(取决于他的 umask)。
对于 e x可执行标志设置 svn-property svn:executable。
.htaccess 文件
您应该将 .htaccess 添加到父目录的 svn:ignore 属性。
但是,SVN 永远不会在没有事先询问您的情况下更改或覆盖您的更改。因此,如果您的某些伙伴将 .accessfile 存储到存储库中,SVN 将停止更新并提示您必须删除自己的 .htaccess 文件才能继续。
回答by vector
1) ... permissions won't transfer.
1) ...权限不会转移。
2) ... update will leave it alone as long as it is not under version control.
2) ...只要它不受版本控制,更新就会不理会它。
That said, double check those ideas. Please.
也就是说,仔细检查这些想法。请。
回答by Amit Suri
An example on how make a file executable:
关于如何使文件可执行的示例:
svn propset svn:executable ON filename

