简体   繁体   English

SVN 结帐忽略文件夹

[英]SVN checkout ignore folder

Can I ignore a folder on svn checkout?我可以忽略 svn 结帐上的文件夹吗? I need to ignore DOCs folder on checkout at my build server.我需要在我的构建服务器结帐时忽略 DOCs 文件夹。

edit: Ignore externals isn't an option.编辑:忽略外部不是一个选项。 I have some externals that I need.我有一些我需要的外部设备。

You can't directly ignore folders on a checkout, but you can use sparse checkouts in svn 1.5. 您不能直接忽略结账时的文件夹,但您可以在svn 1.5中使用稀疏结账。 For example: 例如:

$ svn co http://subversion/project/trunk my_checkout --depth immediates

This will check files and directories from your project trunk into 'my_checkout', but not recurse into those directories. 这会将项目主干中的文件和目录检查到“my_checkout”,但不会递归到这些目录中。 Eg: 例如:

$ cd my_checkout && ls
bar/ baz foo xyzzy/

Then to get the contents of 'bar' down: 然后得到'bar'的内容:

$ cd bar && svn update --set-depth infinity

Yes you can using SVN 1.6. 是的,您可以使用SVN 1.6。 You will need to do a checkout first then mark the folder for exclusion then delete the unwanted folder. 您需要先进行结帐,然后标记要排除的文件夹,然后删除不需要的文件夹。

svn checkout http://www.example.com/project
cd project
svn update --set-depth=exclude docs
rm -fr docs

From now on any updates to the working copy won't repopulate the docs folder. 从现在开始,对工作副本的任何更新都不会重新填充docs文件夹。

See http://blogs.collab.net/subversion/2009/03/sparse-directories-now-with-exclusion/ and http://subversion.apache.org/docs/release-notes/1.6.html#sparse-directory-exclusion for more details. 请参阅http://blogs.collab.net/subversion/2009/03/sparse-directories-now-with-exclusion/http://subversion.apache.org/docs/release-notes/1.6.html#sparse-目录排除更多详细信息。

Tom 汤姆

With versions prior to 1.5 I have found that if you checkout only the top most folder and then selectively update, from then on updates only effect what you have checked out. 对于1.5之前的版本,我发现如果您只签出最顶层的文件夹然后有选择地更新,那么从那时开始更新只会影响你签出的内容。 Ie. IE浏览器。

svn co -N foo
cd foo
svn up -N bar
svn up

The -N flag makes the operation non-recursive. -N标志使操作不是递归的。 The above will not check out anything else at the foo level, eg. 以上内容不会检查foo级别的任何其他内容,例如。 say there is a folder lala , the final svn up will not check out that folder, but it will update bar . lala有一个文件夹,最后svn up不会检查出那个文件夹,但是会更新bar

But at a later time you can svn up lala and thus, add it to the checkout. 但是稍后你可以svn up lala ,然后把它加到收银台。

Presumably this also works with 1.5. 据推测,这也适用于1.5。

This is in TortoiseSVN client 1.7.1 (might be available in some older versions as well): 这是在TortoiseSVN客户端1.7.1(也可能在某些旧版本中可用):

  • SVN checkout --> Select URL of repository SVN签出 - >选择存储库的URL

  • Click on "Checkout Items" (under Checkout Depth) and select only the folders required! 点击“Checkout Items”(Checkout Depth)并选择仅需要的文件夹!

是的, Subversion 1.5有一个名为Sparse checkouts的功能,它可以做到这一点。

您可以将docs文件夹放在外部存储库中,然后使用svn checkout --ignore-externals

I found this question looking for a way to check out the WebKit sources while excluding the regression tests. 我发现这个问题正在寻找一种方法来检查WebKit源,同时排除回归测试。 I ended up with the following: 我最终得到了以下内容:

svn checkout http://svn.webkit.org/repository/webkit/trunk WebKit \
  --depth immediates

cd WebKit
find . \
  -maxdepth 1 -type d \
  -not -name '.*' \
  -not -name '*Tests' \
  -not -name 'Examples' \
  -not -name 'Websites' \
  | (while read SUBDIR; do svn update --set-depth infinity "$SUBDIR"; done)

Note you can change the exclusions as you see fit, but .* is recommended to skip the working directory (which is already up to date) and all of the .svn directories. 请注意,您可以根据需要更改排除项,但。*建议跳过工作目录(已经是最新的)和所有.svn目录。

I have recently resolved the same task. 我最近解决了同样的任务。 The idea is to get the immediate list of folder/files under the repository exclude the entries you need, then check out the remaining folders and update the immediate files if any. 想法是获取存储库下的文件夹/文件的直接列表,排除您需要的条目,然后检查剩余的文件夹并更新即时文件(如果有的话)。 Here is the solution: 这是解决方案:

    # Path to the svn repository to be checked out
rpath=https://svn-repo.company.com/sw/trunk/ && \
    # This files are to be excluded (folders are ending with '/')
    # this is a regex pattern with OR ('|') between enties to be excluded
excludep='docs_folder/tests_folder/|huge_folder/|file1|file2' && \
    # Get list of the files/folders right under the repository path
filtered=`svn ls $rpath | egrep -v $excludep` && \
    # Get list of files out of filtered - they need to be 'uped'
files=`echo $filtered | sed 's| |\n|g' | egrep '^.*[^/]$'` && \
    # Get list of folders out of filtered - they need to be 'coed'
folders=`echo $filtered | sed 's| |\n|g' | egrep '^.*[/]$'` && \
    # Initial nonrecursive checkout of repository - just empty
    # to the current (./) working directory
svn co $rpath ./ --depth empty && \
    # Update the files
svn up $files &&\
    # Check out the all other folders finally.
svn co `echo $folders | sed "s|\<|$rpath|g"`

Change to source working directory. 切换到源工作目录。 Copy the commands. 复制命令。 Paste. 糊。 Change appropriate URL and exclude pattern. 更改相应的URL并排除模式。 Run the command. 运行命令。

Thanks, 谢谢,

No, ignore is only for adding files. 不,忽略仅用于添加文件。
You can use sparse checkouts (if you use svn 1.5) 您可以使用稀疏检出(如果使用svn 1.5)

As a few others have mentioned, you can just use svn:externals properties and then the --ignore-externals option when you checkout. 正如其他一些人所提到的,您可以在结账时使用svn:externals属性,然后使用--ignore-externals选项。 One thing to note, however, is that svn:externals does not necessarily need to refer to another repository. 有一点需要注意,但是,是的svn:的外部不一定需要参考其他资料库。 It can be a reference to some other folder in the same repo. 它可以是同一个仓库中某些其他文件夹的引用。

The best way I have seen is to check out a zero depth version and then go into the directories you need to change and update the depth.我见过的最好的方法是检查零深度版本,然后将 go 放入您需要更改和更新深度的目录中。

Checking out a zero depth folder检出零深度文件夹

$ svn co svn://subversion/project/my_project_dir --depth immediates

Then going into the working folders and adding depth然后进入工作文件夹并增加深度

$ cd my_project_dir
$ cd working_dir && svn update --set-depth infinity

Update as many folders as you need to work on!根据需要更新尽可能多的文件夹!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM