如何在提交期间忽略特定的 Subversion 子目录 [英] How to ignore specific Subversion subdirectories during commit
问题描述
在我当前工作的项目中,有人决定将二进制文件作为源树的一部分签入.二进制文件位于源代码下方的目录中:
project/src #这里是源码的位置project/src/more_src # 这里有更多的源代码project/src/bin # 这里是二进制文件
正如你所想象的,因此合并冲突一直在发生.这很烦人,因为我不认为任何开发人员的机器应该提交二进制文件 - 这应该留给构建服务器.
我是 Subversion 的命令行用户.我想忽略 bin
目录,以便在我使用 svn st
和 svn ci
时跳过这些目录(即使有待处理的更改)).
不幸的是,由于 more_src
目录,我无法使用 -N(非递归).
我怎样才能做到这一点?
edit:subversion 1.6 已经发布.来自发行说明:
<块引用>在 Subversion 1.6 中,--set-depthsvn update 的参数增长了新值——排除.这个值告诉Subversion 将目标排除在外工作副本,立即和直至另行通知.之前Subversion 1.6,如果目录可以不容易从工作中移除复制....
以下所有内容现已过时.
<小时>您可以在正确的位置限制工作副本中文件夹的深度,这样不需要的文件就不会显示为版本化文件.你不能减少现有工作副本的深度.
1) 像这样签出一个干净的工作副本(它将只包含根目录中的文件和空文件夹):
<块引用>svn co --depth 立即 repoURL/some/wc/path
2) 现在对于您不想忽略的每个文件夹,使用
拉入内容svn update --depth infinity/some/good/path
如果要忽略内容的文件夹不在您的工作副本的根目录中,您可以通过重复调用
逐渐沿着树向下移动svn update --depth 立即数/some/path/to/make/deeper
这种方法确实有一个缺点.如果要忽略的文件通过您自己的操作(例如构建)出现在您的工作副本中,它们将在 svn 状态中显示为未版本化的文件.您甚至可以 svn 添加它们并导致文件已存在"提交错误.<小时>显然您可以减少工作副本部分的深度,这要简单得多:
- 正常的项目结帐(或开始来自现有的工作副本)
- 删除不需要的文件夹(正常文件系统删除,而不是 svn rm).此时该文件夹丢失,如果您进行正常更新,它会返回所有恶意内容.
- 带回文件夹
<块引用>
svn update --depth 为空/path/where/deleted/folder/was
现在可以对整个项目进行svn更新,但是坏的内容不会返回.
In the current project I am working in, someone decided that binary files be checked in as part of the source tree. The binaries live in a directory beneath the sources themselves:
project/src # Here is the location of the source code
project/src/more_src # Some more source code lives here
project/src/bin # Here are the binary files
As you can imagine, merge conflicts happen all the time because of this. It's quite annoying since I do not feel that any developer's machine should be committing the binaries - this should be left to the build server.
I am a command-line user of subversion. I would like to ignore the bin
directory so that when I use svn st
and svn ci
these directories are skipped (even if there are pending changes).
Unfortunately, I cannot use -N (non-recursive) because of the more_src
directory.
How can I accomplish this?
edit: subversion 1.6 has been released. From the release notes:
In Subversion 1.6, the --set-depth parameter to svn update has grown a new value—exclude. This value tells Subversion to exclude the target from the working copy, immediately and until further notice. Prior to Subversion 1.6, if a directory could not easily be removed from a working copy. ...
All the stuff below is obsolete now.
You could limit the depth of the folders in your working copy in the right places so that the undesired files don't appear as versioned files. You can't reduce the depth in an existing working copy though.
1) Checkout a clean working copy like this (it will contain only files and empty folders in the root):
svn co --depth immediates repoURL /some/wc/path
2) Now for each folder that you DON'T want to ignore, pull in the content with
svn update --depth infinity /some/good/path
If the folder with content to ignore is not in the root of your working copy, you can work your way down the tree gradually with repeated calls to
svn update --depth immediates /some/path/to/make/deeper
This approach does have a disadvantage. If the files to ignore appear in your working copy through your own actions (e.g. build), they will show up in svn status as unversioned files. You can even svn add them and cause "file already exists" commit errors.
edit: Apparently you CAN reduce the depth of parts of your working copy, which is much simpler:
- normal project checkout (or start from existing working copy)
- delete undesired folder (normal filesystem delete, not svn rm). At this point the folder is missing and would return with all it's evil content if you did a normal update.
- bring back the folder with
svn update --depth empty /path/where/deleted/folder/was
Now you can do svn update of the entire project but the bad content will not return.
这篇关于如何在提交期间忽略特定的 Subversion 子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!