SVN: Checkout/export only the directory structure

后端 未结 12 1111
花落未央
花落未央 2020-12-08 19:14

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条回答
  • 2020-12-08 19:59

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

    0 讨论(0)
  • 2020-12-08 20:01

    A use for checking out just the directory structure is a partial workaround for not being able to exclude one or more directories from being checked out. It is assumed that the cost of just checking out the directory tree is negligible in comparison to checking out the full source. With a versioned directory structure checked out I could then use Subversion's update and sparse directories to selectively pick what directory trees should have files.

    0 讨论(0)
  • 2020-12-08 20:01

    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 ...

    0 讨论(0)
  • 2020-12-08 20:04
    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.

    0 讨论(0)
  • 2020-12-08 20:05

    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.

    0 讨论(0)
  • 2020-12-08 20:05

    Just wanted to add, if you need to do this server-side (i.e. not checking out the repository first), the equivalent to svn ls is svnlook tree --full-paths. I had to create a copy of a 50GB repo's folder structure and used the hints I found here to do it without having to create a working copy of the whole thing.

    My code was:

    svnlook tree /path/to/repo --full-paths | grep "/$" | grep -v "^/$" | xargs -I {} mkdir -p "{}"

    The grep -v "^/$" because the output contained a single / (i.e. file system root folder) and I didn't want to mess around with that.

    0 讨论(0)
提交回复
热议问题