SVN: Checkout/export only the directory structure

2019-01-17 09:50发布

Is there a way to perform a SVN checkout (or export), which would fetch only the directory structure; that is to say, no files?

12条回答
做自己的国王
2楼-- · 2019-01-17 10:15

You can specify --non-recursive to the checkout command, might help you to get what you want.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-17 10:18
svn ls -R {svnrepo} | grep "/$" | xargs -n 1 mkdir -p

Export, not a checkout.

[Updated]

With checkout:

env REPO={repo} sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth=empty $REPO'

This will be pretty slow for anything too large.

查看更多
你好瞎i
4楼-- · 2019-01-17 10:21

on windows and with TortoiseSVN you can do Checkout -> checkout depth: only this item. this way you can get single folders/files. you could rebuild your structure this way (using the repobrowser). a bit cumbersome, but doable if your directory structure is not too complicated. i preferred this over checking out thousands of small files (several gigabytes) over slow network ...

查看更多
够拽才男人
5楼-- · 2019-01-17 10:24

You may use this script which will svn list the repos and create the structure in a directory.

usage: perl checkout-structure.pl repos destdir

repos must not be the root of your repos, it can also precise a directory.

Fails to create dirs containing accentuated caracters (àéîùç...), but works fine with spaces. For these who have time for that, I think it's an encoding problem.

checkout-structure.pl:

#!perl

my @dirs;
my $repos = shift;
my $dest = shift;

@dirs = grep { /\/$/ && /^[^\.]/ } `svn list -R $repos`;

foreach(@dirs) {
    s/\/$//;
    chomp;
    mkdir("$dest/$_") or warn $!." trying to create $dest/$_";
}
查看更多
放我归山
6楼-- · 2019-01-17 10:25

There is a python script in the contrib tools of subversion, which creates the directory structure with empty files. With a little bit of python knowledge, it should not be to hard to skip creating the files at all.

查看更多
聊天终结者
7楼-- · 2019-01-17 10:25

SVN can't do that per se, but if you just want to export directory structure, try svn ls -R --xml to get XML listing of the directory structure and then recreate it by hand.

查看更多
登录 后发表回答